import{n as e}from"./rolldown-runtime-Dl_DZoUm.js";import{i as t,t as n}from"./react-1o5M9n0k.js";import{A as r,C as i,D as a,E as o,F as s,I as c,L as l,M as u,N as d,O as f,P as p,R as m,S as h,T as g,_,a as v,b as y,c as b,g as x,h as S,i as C,j as w,k as T,l as E,n as D,o as O,s as k,v as A,w as j,y as ee,z as M}from"./index-D-ox0wtk.js";import{$ as te,A as ne,B as re,Cn as N,Dn as ie,En as P,Ft as ae,G as oe,H as se,J as ce,M as le,N as ue,Nt as de,O as fe,P as pe,St as F,T as me,Tn as he,Tt as ge,V as _e,Z as ve,Zt as ye,_ as be,at as xe,bn as Se,bt as Ce,dn as we,ht as Te,i as Ee,k as De,lt as I,mt as Oe,nn as ke,nt as Ae,ot as je,pt as Me,q as Ne,qt as L,rn as Pe,tn as Fe,ut as Ie,wn as Le,x as Re,xn as R,y as z}from"./skeleton-B4Z0R3jQ.js";import{d as ze,f as Be,h as Ve,m as He,n as Ue,p as We,t as Ge,u as Ke}from"./typography-xRg_3Gco.js";import{a as qe,o as B,r as Je,s as Ye}from"./shared-DZLPF0cC.js";import{n as Xe,t as Ze}from"./useOrderForm-Boa1k5nR.js";import{a as Qe,d as $e,f as et,i as tt,n as nt,r as rt,t as it,u as at}from"./LockOutlined-BPg5cH36.js";import{n as ot,r as st,t as ct}from"./input-BnsACfRy.js";import{n as lt,t as ut}from"./ReloadOutlined-BW5sy5GM.js";var dt={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z`}}]},name:`right`,theme:`outlined`},V=e(t()),ft=V.forwardRef(function(e,t){return V.createElement(ve,P({},e,{ref:t,icon:dt}))}),H=e(ie()),pt=V.forwardRef(function(e,t){var n=e.prefixCls,r=e.forceRender,i=e.className,a=e.style,o=e.children,s=e.isActive,c=e.role,l=e.classNames,u=e.styles,d=V.useState(s||r),f=Fe(d,2),p=f[0],m=f[1];return V.useEffect(function(){(r||s)&&m(!0)},[r,s]),p?V.createElement(`div`,{ref:t,className:(0,H.default)(`${n}-content`,R(R({},`${n}-content-active`,s),`${n}-content-inactive`,!s),i),style:a,role:c},V.createElement(`div`,{className:(0,H.default)(`${n}-content-box`,l?.body),style:u?.body},o)):null});pt.displayName=`PanelContent`;var mt=[`showArrow`,`headerClass`,`isActive`,`onItemClick`,`forceRender`,`className`,`classNames`,`styles`,`prefixCls`,`collapsible`,`accordion`,`panelKey`,`extra`,`header`,`expandIcon`,`openMotion`,`destroyInactivePanel`,`children`],ht=V.forwardRef(function(e,t){var n=e.showArrow,r=n===void 0||n,i=e.headerClass,a=e.isActive,o=e.onItemClick,s=e.forceRender,c=e.className,l=e.classNames,u=l===void 0?{}:l,d=e.styles,f=d===void 0?{}:d,p=e.prefixCls,m=e.collapsible,h=e.accordion,g=e.panelKey,_=e.extra,v=e.header,y=e.expandIcon,b=e.openMotion,x=e.destroyInactivePanel,S=e.children,C=ye(e,mt),w=m===`disabled`,T=_!=null&&typeof _!=`boolean`,E=R(R(R({onClick:function(){o?.(g)},onKeyDown:function(e){(e.key===`Enter`||e.keyCode===re.ENTER||e.which===re.ENTER)&&o?.(g)},role:h?`tab`:`button`},`aria-expanded`,a),`aria-disabled`,w),`tabIndex`,w?-1:0),D=typeof y==`function`?y(e):V.createElement(`i`,{className:`arrow`}),O=D&&V.createElement(`div`,P({className:`${p}-expand-icon`},[`header`,`icon`].includes(m)?E:{}),D),k=(0,H.default)(`${p}-item`,R(R({},`${p}-item-active`,a),`${p}-item-disabled`,w),c),A=(0,H.default)(i,`${p}-header`,R({},`${p}-collapsible-${m}`,!!m),u.header),j=Se({className:A,style:f.header},[`header`,`icon`].includes(m)?{}:E);return V.createElement(`div`,P({},C,{ref:t,className:k}),V.createElement(`div`,j,r&&O,V.createElement(`span`,P({className:`${p}-header-text`},m===`header`?E:{}),v),T&&V.createElement(`div`,{className:`${p}-extra`},_)),V.createElement(te,P({visible:a,leavedClassName:`${p}-content-hidden`},b,{forceRender:s,removeOnLeave:x}),function(e,t){var n=e.className,r=e.style;return V.createElement(pt,{ref:t,prefixCls:p,className:n,classNames:u,style:r,styles:f,isActive:a,forceRender:s,role:h?`tabpanel`:void 0},S)}))}),gt=[`children`,`label`,`key`,`collapsible`,`onItemClick`,`destroyInactivePanel`],_t=function(e,t){var n=t.prefixCls,r=t.accordion,i=t.collapsible,a=t.destroyInactivePanel,o=t.onItemClick,s=t.activeKey,c=t.openMotion,l=t.expandIcon;return e.map(function(e,t){var u=e.children,d=e.label,f=e.key,p=e.collapsible,m=e.onItemClick,h=e.destroyInactivePanel,g=ye(e,gt),_=String(f??t),v=p??i,y=h??a,b=function(e){v!==`disabled`&&(o(e),m?.(e))},x=!1;return x=r?s[0]===_:s.indexOf(_)>-1,V.createElement(ht,P({},g,{prefixCls:n,key:_,panelKey:_,isActive:x,accordion:r,openMotion:c,expandIcon:l,header:d,collapsible:v,onItemClick:b,destroyInactivePanel:y}),u)})},vt=function(e,t,n){if(!e)return null;var r=n.prefixCls,i=n.accordion,a=n.collapsible,o=n.destroyInactivePanel,s=n.onItemClick,c=n.activeKey,l=n.openMotion,u=n.expandIcon,d=e.key||String(t),f=e.props,p=f.header,m=f.headerClass,h=f.destroyInactivePanel,g=f.collapsible,_=f.onItemClick,v=!1;v=i?c[0]===d:c.indexOf(d)>-1;var y=g??a,b={key:d,panelKey:d,header:p,headerClass:m,isActive:v,prefixCls:r,destroyInactivePanel:h??o,openMotion:l,accordion:i,children:e.props.children,onItemClick:function(e){y!==`disabled`&&(s(e),_?.(e))},expandIcon:u,collapsible:y};return typeof e.type==`string`?e:(Object.keys(b).forEach(function(e){b[e]===void 0&&delete b[e]}),V.cloneElement(e,b))};function yt(e,t,n){return Array.isArray(e)?_t(e,n):Le(t).map(function(e,t){return vt(e,t,n)})}function bt(e){var t=e;if(!Array.isArray(t)){var n=he(t);t=n===`number`||n===`string`?[t]:[]}return t.map(function(e){return String(e)})}var xt=Object.assign(V.forwardRef(function(e,t){var n=e.prefixCls,r=n===void 0?`rc-collapse`:n,i=e.destroyInactivePanel,a=i!==void 0&&i,o=e.style,s=e.accordion,c=e.className,l=e.children,u=e.collapsible,d=e.openMotion,f=e.expandIcon,p=e.activeKey,m=e.defaultActiveKey,h=e.onChange,g=e.items,_=(0,H.default)(r,c),v=Te([],{value:p,onChange:function(e){return h?.(e)},defaultValue:m,postState:bt}),y=Fe(v,2),b=y[0],x=y[1],S=function(e){return x(function(){return s?b[0]===e?[]:[e]:b.indexOf(e)>-1?b.filter(function(t){return t!==e}):[].concat(Pe(b),[e])})};N(!l,"[rc-collapse] `children` will be removed in next major version. Please use `items` instead.");var C=yt(g,l,{prefixCls:r,accordion:s,openMotion:d,expandIcon:f,collapsible:u,destroyInactivePanel:a,onItemClick:S,activeKey:b});return V.createElement(`div`,P({ref:t,className:_,style:o,role:s?`tablist`:void 0},oe(e,{aria:!0,data:!0})),C)}),{Panel:ht}),St=xt;xt.Panel;var Ct=V.forwardRef((e,t)=>{let{getPrefixCls:n}=V.useContext(F),{prefixCls:r,className:i,showArrow:a=!0}=e,o=n(`collapse`,r),s=(0,H.default)({[`${o}-no-arrow`]:!a},i);return V.createElement(St.Panel,Object.assign({ref:t},e,{prefixCls:o,className:s}))}),wt=e=>{let{componentCls:t,contentBg:n,padding:r,headerBg:i,headerPadding:a,collapseHeaderPaddingSM:o,collapseHeaderPaddingLG:s,collapsePanelBorderRadius:c,lineWidth:l,lineType:u,colorBorder:d,colorText:f,colorTextHeading:p,colorTextDisabled:m,fontSizeLG:h,lineHeight:g,lineHeightLG:_,marginSM:v,paddingSM:y,paddingLG:b,paddingXS:x,motionDurationSlow:S,fontSizeIcon:C,contentPadding:w,fontHeight:T,fontHeightLG:E}=e,D=`${L(l)} ${u} ${d}`;return{[t]:Object.assign(Object.assign({},I(e)),{backgroundColor:i,border:D,borderRadius:c,"&-rtl":{direction:`rtl`},[`& > ${t}-item`]:{borderBottom:D,"&:first-child":{[` &, & > ${t}-header`]:{borderRadius:`${L(c)} ${L(c)} 0 0`}},"&:last-child":{[` &, & > ${t}-header`]:{borderRadius:`0 0 ${L(c)} ${L(c)}`}},[`> ${t}-header`]:Object.assign(Object.assign({position:`relative`,display:`flex`,flexWrap:`nowrap`,alignItems:`flex-start`,padding:a,color:p,lineHeight:g,cursor:`pointer`,transition:`all ${S}, visibility 0s`},je(e)),{[`> ${t}-header-text`]:{flex:`auto`},[`${t}-expand-icon`]:{height:T,display:`flex`,alignItems:`center`,paddingInlineEnd:v},[`${t}-arrow`]:Object.assign(Object.assign({},Ie()),{fontSize:C,transition:`transform ${S}`,svg:{transition:`transform ${S}`}}),[`${t}-header-text`]:{marginInlineEnd:`auto`}}),[`${t}-collapsible-header`]:{cursor:`default`,[`${t}-header-text`]:{flex:`none`,cursor:`pointer`},[`${t}-expand-icon`]:{cursor:`pointer`}},[`${t}-collapsible-icon`]:{cursor:`unset`,[`${t}-expand-icon`]:{cursor:`pointer`}}},[`${t}-content`]:{color:f,backgroundColor:n,borderTop:D,[`& > ${t}-content-box`]:{padding:w},"&-hidden":{display:`none`}},"&-small":{[`> ${t}-item`]:{[`> ${t}-header`]:{padding:o,paddingInlineStart:x,[`> ${t}-expand-icon`]:{marginInlineStart:e.calc(y).sub(x).equal()}},[`> ${t}-content > ${t}-content-box`]:{padding:y}}},"&-large":{[`> ${t}-item`]:{fontSize:h,lineHeight:_,[`> ${t}-header`]:{padding:s,paddingInlineStart:r,[`> ${t}-expand-icon`]:{height:E,marginInlineStart:e.calc(b).sub(r).equal()}},[`> ${t}-content > ${t}-content-box`]:{padding:b}}},[`${t}-item:last-child`]:{borderBottom:0,[`> ${t}-content`]:{borderRadius:`0 0 ${L(c)} ${L(c)}`}},[`& ${t}-item-disabled > ${t}-header`]:{"\n &,\n & > .arrow\n ":{color:m,cursor:`not-allowed`}},[`&${t}-icon-position-end`]:{[`& > ${t}-item`]:{[`> ${t}-header`]:{[`${t}-expand-icon`]:{order:1,paddingInlineEnd:0,paddingInlineStart:v}}}}})}},Tt=e=>{let{componentCls:t}=e,n=`> ${t}-item > ${t}-header ${t}-arrow`;return{[`${t}-rtl`]:{[n]:{transform:`rotate(180deg)`}}}},Et=e=>{let{componentCls:t,headerBg:n,borderlessContentPadding:r,borderlessContentBg:i,colorBorder:a}=e;return{[`${t}-borderless`]:{backgroundColor:n,border:0,[`> ${t}-item`]:{borderBottom:`1px solid ${a}`},[` > ${t}-item:last-child, > ${t}-item:last-child ${t}-header `]:{borderRadius:0},[`> ${t}-item:last-child`]:{borderBottom:0},[`> ${t}-item > ${t}-content`]:{backgroundColor:i,borderTop:0},[`> ${t}-item > ${t}-content > ${t}-content-box`]:{padding:r}}}},Dt=e=>{let{componentCls:t,paddingSM:n}=e;return{[`${t}-ghost`]:{backgroundColor:`transparent`,border:0,[`> ${t}-item`]:{borderBottom:0,[`> ${t}-content`]:{backgroundColor:`transparent`,border:0,[`> ${t}-content-box`]:{paddingBlock:n}}}}}},Ot=Ae(`Collapse`,e=>{let t=Oe(e,{collapseHeaderPaddingSM:`${L(e.paddingXS)} ${L(e.paddingSM)}`,collapseHeaderPaddingLG:`${L(e.padding)} ${L(e.paddingLG)}`,collapsePanelBorderRadius:e.borderRadiusLG});return[wt(t),Et(t),Dt(t),Tt(t),et(t)]},e=>({headerPadding:`${e.paddingSM}px ${e.padding}px`,headerBg:e.colorFillAlter,contentPadding:`${e.padding}px 16px`,contentBg:e.colorBgContainer,borderlessContentPadding:`${e.paddingXXS}px 16px ${e.padding}px`,borderlessContentBg:`transparent`})),kt=Object.assign(V.forwardRef((e,t)=>{let{getPrefixCls:n,direction:r,expandIcon:i,className:a,style:o}=ge(`collapse`),{prefixCls:s,className:c,rootClassName:l,style:u,bordered:d=!0,ghost:f,size:p,expandIconPosition:m=`start`,children:h,destroyInactivePanel:g,destroyOnHidden:_,expandIcon:v}=e,y=fe(e=>p??e??`middle`),b=n(`collapse`,s),x=n(),[S,C,w]=Ot(b),T=V.useMemo(()=>m===`left`?`start`:m===`right`?`end`:m,[m]),E=v??i,D=V.useCallback((e={})=>{let t=typeof E==`function`?E(e):V.createElement(ft,{rotate:e.isActive?r===`rtl`?-90:90:void 0,"aria-label":e.isActive?`expanded`:`collapsed`});return se(t,()=>({className:(0,H.default)(t.props?.className,`${b}-arrow`)}))},[E,b,r]),O=(0,H.default)(`${b}-icon-position-${T}`,{[`${b}-borderless`]:!d,[`${b}-rtl`]:r===`rtl`,[`${b}-ghost`]:!!f,[`${b}-${y}`]:y!==`middle`},a,c,l,C,w),k=V.useMemo(()=>Object.assign(Object.assign({},pe(x)),{motionAppear:!1,leavedClassName:`${b}-content-hidden`}),[x,b]),A=V.useMemo(()=>h?Le(h).map((e,t)=>{let n=e.props;if(n?.disabled){let r=e.key??String(t),i=Object.assign(Object.assign({},le(e.props,[`disabled`])),{key:r,collapsible:n.collapsible??`disabled`});return se(e,i)}return e}):null,[h]);return S(V.createElement(St,Object.assign({ref:t,openMotion:k},le(e,[`rootClassName`]),{expandIcon:D,prefixCls:b,className:O,style:Object.assign(Object.assign({},o),u),destroyInactivePanel:_??g}),A))}),{Panel:Ct}),At=e=>e?typeof e==`function`?e():e:null,jt=e=>{let{componentCls:t,popoverColor:n,titleMinWidth:r,fontWeightStrong:i,innerPadding:a,boxShadowSecondary:o,colorTextHeading:s,borderRadiusLG:c,zIndexPopup:l,titleMarginBottom:u,colorBgElevated:d,popoverBg:f,titleBorderBottom:p,innerContentPadding:m,titlePadding:h}=e;return[{[t]:Object.assign(Object.assign({},I(e)),{position:`absolute`,top:0,left:{_skip_check_:!0,value:0},zIndex:l,fontWeight:`normal`,whiteSpace:`normal`,textAlign:`start`,cursor:`auto`,userSelect:`text`,"--valid-offset-x":`var(--arrow-offset-horizontal, var(--arrow-x))`,transformOrigin:`var(--valid-offset-x, 50%) var(--arrow-y, 50%)`,"--antd-arrow-background-color":d,width:`max-content`,maxWidth:`100vw`,"&-rtl":{direction:`rtl`},"&-hidden":{display:`none`},[`${t}-content`]:{position:`relative`},[`${t}-inner`]:{backgroundColor:f,backgroundClip:`padding-box`,borderRadius:c,boxShadow:o,padding:a},[`${t}-title`]:{minWidth:r,marginBottom:u,color:s,fontWeight:i,borderBottom:p,padding:h},[`${t}-inner-content`]:{color:n,padding:m}})},Be(e,`var(--antd-arrow-background-color)`),{[`${t}-pure`]:{position:`relative`,maxWidth:`none`,margin:e.sizePopupArrow,display:`inline-block`,[`${t}-content`]:{display:`inline-block`}}}]},Mt=e=>{let{componentCls:t}=e;return{[t]:Me.map(n=>{let r=e[`${n}6`];return{[`&${t}-${n}`]:{"--antd-arrow-background-color":r,[`${t}-inner`]:{backgroundColor:r},[`${t}-arrow`]:{background:`transparent`}}}})}},Nt=Ae(`Popover`,e=>{let{colorBgElevated:t,colorText:n}=e,r=Oe(e,{popoverBg:t,popoverColor:n});return[jt(r),Mt(r),Re(r,`zoom-big`)]},e=>{let{lineWidth:t,controlHeight:n,fontHeight:r,padding:i,wireframe:a,zIndexPopupBase:o,borderRadiusLG:s,marginXS:c,lineType:l,colorSplit:u,paddingSM:d}=e,f=n-r,p=f/2,m=f/2-t,h=i;return Object.assign(Object.assign(Object.assign({titleMinWidth:177,zIndexPopup:o+30},We(e)),ze({contentRadius:s,limitVerticalRadius:!0})),{innerPadding:a?0:12,titleMarginBottom:a?0:c,titlePadding:a?`${p}px ${h}px ${m}px`:0,titleBorderBottom:a?`${t}px ${l} ${u}`:`none`,innerContentPadding:a?`${d}px ${h}px`:0})},{resetStyle:!1,deprecatedTokens:[[`width`,`titleMinWidth`],[`minWidth`,`titleMinWidth`]]}),Pt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i!e&&!t?null:V.createElement(V.Fragment,null,e&&V.createElement(`div`,{className:`${n}-title`},e),t&&V.createElement(`div`,{className:`${n}-inner-content`},t)),It=e=>{let{hashId:t,prefixCls:n,className:r,style:i,placement:a=`top`,title:o,content:s,children:c}=e,l=At(o),u=At(s),d=(0,H.default)(t,n,`${n}-pure`,`${n}-placement-${a}`,r);return V.createElement(`div`,{className:d,style:i},V.createElement(`div`,{className:`${n}-arrow`}),V.createElement(He,Object.assign({},e,{className:t,prefixCls:n}),c||V.createElement(Ft,{prefixCls:n,title:l,content:u})))},Lt=e=>{let{prefixCls:t,className:n}=e,r=Pt(e,[`prefixCls`,`className`]),{getPrefixCls:i}=V.useContext(F),a=i(`popover`,t),[o,s,c]=Nt(a);return o(V.createElement(It,Object.assign({},r,{prefixCls:a,hashId:s,className:(0,H.default)(n,c)})))},Rt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let{prefixCls:n,title:r,content:i,overlayClassName:a,placement:o=`top`,trigger:s=`hover`,children:c,mouseEnterDelay:l=.1,mouseLeaveDelay:u=.1,onOpenChange:d,overlayStyle:f={},styles:p,classNames:m}=e,h=Rt(e,[`prefixCls`,`title`,`content`,`overlayClassName`,`placement`,`trigger`,`children`,`mouseEnterDelay`,`mouseLeaveDelay`,`onOpenChange`,`overlayStyle`,`styles`,`classNames`]),{getPrefixCls:g,className:_,style:v,classNames:y,styles:b}=ge(`popover`),x=g(`popover`,n),[S,C,w]=Nt(x),T=g(),E=(0,H.default)(a,C,w,_,y.root,m?.root),D=(0,H.default)(y.body,m?.body),[O,k]=Te(!1,{value:e.open??e.visible,defaultValue:e.defaultOpen??e.defaultVisible}),A=(e,t)=>{k(e,!0),d?.(e,t)},j=e=>{e.keyCode===re.ESC&&A(!1,e)},ee=e=>{A(e)},M=At(r),te=At(i);return S(V.createElement(Ke,Object.assign({placement:o,trigger:s,mouseEnterDelay:l,mouseLeaveDelay:u},h,{prefixCls:x,classNames:{root:E,body:D},styles:{root:Object.assign(Object.assign(Object.assign(Object.assign({},b.root),v),f),p?.root),body:Object.assign(Object.assign({},b.body),p?.body)},ref:t,open:O,onOpenChange:ee,overlay:M||te?V.createElement(Ft,{prefixCls:x,title:M,content:te}):null,transitionName:ue(T,`zoom-big`,h.transitionName),"data-popover-inject":!0}),se(c,{onKeyDown:e=>{var t,n;(0,V.isValidElement)(c)&&((n=c==null?void 0:(t=c.props).onKeyDown)==null||n.call(t,e)),j(e)}})))});zt._InternalPanelDoNotUseOrYouWillBeFired=Lt;var Bt=V.createContext(null),Vt=Bt.Provider,Ht=V.createContext(null),Ut=Ht.Provider,Wt=[`prefixCls`,`className`,`style`,`checked`,`disabled`,`defaultChecked`,`type`,`title`,`onChange`],Gt=(0,V.forwardRef)(function(e,t){var n=e.prefixCls,r=n===void 0?`rc-checkbox`:n,i=e.className,a=e.style,o=e.checked,s=e.disabled,c=e.defaultChecked,l=c!==void 0&&c,u=e.type,d=u===void 0?`checkbox`:u,f=e.title,p=e.onChange,m=ye(e,Wt),h=(0,V.useRef)(null),g=(0,V.useRef)(null),_=Te(l,{value:o}),v=Fe(_,2),y=v[0],b=v[1];(0,V.useImperativeHandle)(t,function(){return{focus:function(e){var t;(t=h.current)==null||t.focus(e)},blur:function(){var e;(e=h.current)==null||e.blur()},input:h.current,nativeElement:g.current}});var x=(0,H.default)(r,i,R(R({},`${r}-checked`,y),`${r}-disabled`,s));return V.createElement(`span`,{className:x,title:f,style:a,ref:g},V.createElement(`input`,P({},m,{className:`${r}-input`,ref:h,onChange:function(t){s||(`checked`in e||b(t.target.checked),p?.({target:Se(Se({},e),{},{type:d,checked:t.target.checked}),stopPropagation:function(){t.stopPropagation()},preventDefault:function(){t.preventDefault()},nativeEvent:t.nativeEvent}))},disabled:s,checked:!!y,type:d})),V.createElement(`span`,{className:`${r}-inner`}))});function Kt(e){let t=V.useRef(null),n=()=>{ke.cancel(t.current),t.current=null};return[()=>{n(),t.current=ke(()=>{t.current=null})},r=>{t.current&&(r.stopPropagation(),n()),e?.(r)}]}var qt=e=>{let{componentCls:t,antCls:n}=e,r=`${t}-group`;return{[r]:Object.assign(Object.assign({},I(e)),{display:`inline-block`,fontSize:0,[`&${r}-rtl`]:{direction:`rtl`},[`&${r}-block`]:{display:`flex`},[`${n}-badge ${n}-badge-count`]:{zIndex:1},[`> ${n}-badge:not(:first-child) > ${n}-button-wrapper`]:{borderInlineStart:`none`}})}},Jt=e=>{let{componentCls:t,wrapperMarginInlineEnd:n,colorPrimary:r,radioSize:i,motionDurationSlow:a,motionDurationMid:o,motionEaseInOutCirc:s,colorBgContainer:c,colorBorder:l,lineWidth:u,colorBgContainerDisabled:d,colorTextDisabled:f,paddingXS:p,dotColorDisabled:m,lineType:h,radioColor:g,radioBgColor:_,calc:v}=e,y=`${t}-inner`,b=v(i).sub(v(4).mul(2)),x=v(1).mul(i).equal({unit:!0});return{[`${t}-wrapper`]:Object.assign(Object.assign({},I(e)),{display:`inline-flex`,alignItems:`baseline`,marginInlineStart:0,marginInlineEnd:n,cursor:`pointer`,"&:last-child":{marginInlineEnd:0},[`&${t}-wrapper-rtl`]:{direction:`rtl`},"&-disabled":{cursor:`not-allowed`,color:e.colorTextDisabled},"&::after":{display:`inline-block`,width:0,overflow:`hidden`,content:`"\\a0"`},"&-block":{flex:1,justifyContent:`center`},[`${t}-checked::after`]:{position:`absolute`,insetBlockStart:0,insetInlineStart:0,width:`100%`,height:`100%`,border:`${L(u)} ${h} ${r}`,borderRadius:`50%`,visibility:`hidden`,opacity:0,content:`""`},[t]:Object.assign(Object.assign({},I(e)),{position:`relative`,display:`inline-block`,outline:`none`,cursor:`pointer`,alignSelf:`center`,borderRadius:`50%`}),[`${t}-wrapper:hover &, &:hover ${y}`]:{borderColor:r},[`${t}-input:focus-visible + ${y}`]:xe(e),[`${t}:hover::after, ${t}-wrapper:hover &::after`]:{visibility:`visible`},[`${t}-inner`]:{"&::after":{boxSizing:`border-box`,position:`absolute`,insetBlockStart:`50%`,insetInlineStart:`50%`,display:`block`,width:x,height:x,marginBlockStart:v(1).mul(i).div(-2).equal({unit:!0}),marginInlineStart:v(1).mul(i).div(-2).equal({unit:!0}),backgroundColor:g,borderBlockStart:0,borderInlineStart:0,borderRadius:x,transform:`scale(0)`,opacity:0,transition:`all ${a} ${s}`,content:`""`},boxSizing:`border-box`,position:`relative`,insetBlockStart:0,insetInlineStart:0,display:`block`,width:x,height:x,backgroundColor:c,borderColor:l,borderStyle:`solid`,borderWidth:u,borderRadius:`50%`,transition:`all ${o}`},[`${t}-input`]:{position:`absolute`,inset:0,zIndex:1,cursor:`pointer`,opacity:0},[`${t}-checked`]:{[y]:{borderColor:r,backgroundColor:_,"&::after":{transform:`scale(${e.calc(e.dotSize).div(i).equal()})`,opacity:1,transition:`all ${a} ${s}`}}},[`${t}-disabled`]:{cursor:`not-allowed`,[y]:{backgroundColor:d,borderColor:l,cursor:`not-allowed`,"&::after":{backgroundColor:m}},[`${t}-input`]:{cursor:`not-allowed`},[`${t}-disabled + span`]:{color:f,cursor:`not-allowed`},[`&${t}-checked`]:{[y]:{"&::after":{transform:`scale(${v(b).div(i).equal()})`}}}},[`span${t} + *`]:{paddingInlineStart:p,paddingInlineEnd:p}})}},Yt=e=>{let{buttonColor:t,controlHeight:n,componentCls:r,lineWidth:i,lineType:a,colorBorder:o,motionDurationMid:s,buttonPaddingInline:c,fontSize:l,buttonBg:u,fontSizeLG:d,controlHeightLG:f,controlHeightSM:p,paddingXS:m,borderRadius:h,borderRadiusSM:g,borderRadiusLG:_,buttonCheckedBg:v,buttonSolidCheckedColor:y,colorTextDisabled:b,colorBgContainerDisabled:x,buttonCheckedBgDisabled:S,buttonCheckedColorDisabled:C,colorPrimary:w,colorPrimaryHover:T,colorPrimaryActive:E,buttonSolidCheckedBg:D,buttonSolidCheckedHoverBg:O,buttonSolidCheckedActiveBg:k,calc:A}=e;return{[`${r}-button-wrapper`]:{position:`relative`,display:`inline-block`,height:n,margin:0,paddingInline:c,paddingBlock:0,color:t,fontSize:l,lineHeight:L(A(n).sub(A(i).mul(2)).equal()),background:u,border:`${L(i)} ${a} ${o}`,borderBlockStartWidth:A(i).add(.02).equal(),borderInlineEndWidth:i,cursor:`pointer`,transition:[`color ${s}`,`background ${s}`,`box-shadow ${s}`].join(`,`),a:{color:t},[`> ${r}-button`]:{position:`absolute`,insetBlockStart:0,insetInlineStart:0,zIndex:-1,width:`100%`,height:`100%`},"&:not(:last-child)":{marginInlineEnd:A(i).mul(-1).equal()},"&:first-child":{borderInlineStart:`${L(i)} ${a} ${o}`,borderStartStartRadius:h,borderEndStartRadius:h},"&:last-child":{borderStartEndRadius:h,borderEndEndRadius:h},"&:first-child:last-child":{borderRadius:h},[`${r}-group-large &`]:{height:f,fontSize:d,lineHeight:L(A(f).sub(A(i).mul(2)).equal()),"&:first-child":{borderStartStartRadius:_,borderEndStartRadius:_},"&:last-child":{borderStartEndRadius:_,borderEndEndRadius:_}},[`${r}-group-small &`]:{height:p,paddingInline:A(m).sub(i).equal(),paddingBlock:0,lineHeight:L(A(p).sub(A(i).mul(2)).equal()),"&:first-child":{borderStartStartRadius:g,borderEndStartRadius:g},"&:last-child":{borderStartEndRadius:g,borderEndEndRadius:g}},"&:hover":{position:`relative`,color:w},"&:has(:focus-visible)":xe(e),[`${r}-inner, input[type='checkbox'], input[type='radio']`]:{width:0,height:0,opacity:0,pointerEvents:`none`},[`&-checked:not(${r}-button-wrapper-disabled)`]:{zIndex:1,color:w,background:v,borderColor:w,"&::before":{backgroundColor:w},"&:first-child":{borderColor:w},"&:hover":{color:T,borderColor:T,"&::before":{backgroundColor:T}},"&:active":{color:E,borderColor:E,"&::before":{backgroundColor:E}}},[`${r}-group-solid &-checked:not(${r}-button-wrapper-disabled)`]:{color:y,background:D,borderColor:D,"&:hover":{color:y,background:O,borderColor:O},"&:active":{color:y,background:k,borderColor:k}},"&-disabled":{color:b,backgroundColor:x,borderColor:o,cursor:`not-allowed`,"&:first-child, &:hover":{color:b,backgroundColor:x,borderColor:o}},[`&-disabled${r}-button-wrapper-checked`]:{color:C,backgroundColor:S,borderColor:o,boxShadow:`none`},"&-block":{flex:1,textAlign:`center`}}}},Xt=Ae(`Radio`,e=>{let{controlOutline:t,controlOutlineWidth:n}=e,r=`0 0 0 ${L(n)} ${t}`,i=Oe(e,{radioFocusShadow:r,radioButtonFocusShadow:r});return[qt(i),Jt(i),Yt(i)]},e=>{let{wireframe:t,padding:n,marginXS:r,lineWidth:i,fontSizeLG:a,colorText:o,colorBgContainer:s,colorTextDisabled:c,controlItemBgActiveDisabled:l,colorTextLightSolid:u,colorPrimary:d,colorPrimaryHover:f,colorPrimaryActive:p,colorWhite:m}=e,h=a;return{radioSize:h,dotSize:t?h-8:h-(4+i)*2,dotColorDisabled:c,buttonSolidCheckedColor:u,buttonSolidCheckedBg:d,buttonSolidCheckedHoverBg:f,buttonSolidCheckedActiveBg:p,buttonBg:s,buttonCheckedBg:s,buttonColor:o,buttonCheckedBgDisabled:l,buttonCheckedColorDisabled:c,buttonPaddingInline:n-i,wrapperMarginInlineEnd:r,radioColor:t?d:m,radioBgColor:t?s:d}},{unitless:{radioSize:!0,dotSize:!0}}),Zt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let n=V.useContext(Bt),r=V.useContext(Ht),{getPrefixCls:i,direction:a,radio:o}=V.useContext(F),s=V.useRef(null),c=we(t,s),{isFormItemInput:l}=V.useContext(Ee),u=t=>{var r,i;(r=e.onChange)==null||r.call(e,t),(i=n?.onChange)==null||i.call(n,t)},{prefixCls:d,className:f,rootClassName:p,children:m,style:h,title:g}=e,_=Zt(e,[`prefixCls`,`className`,`rootClassName`,`children`,`style`,`title`]),v=i(`radio`,d),y=(n?.optionType||r)===`button`,b=y?`${v}-button`:v,x=_e(v),[S,C,w]=Xt(v,x),T=Object.assign({},_),E=V.useContext(Ce);n&&(T.name=n.name,T.onChange=u,T.checked=e.value===n.value,T.disabled=T.disabled??n.disabled),T.disabled=T.disabled??E;let D=(0,H.default)(`${b}-wrapper`,{[`${b}-wrapper-checked`]:T.checked,[`${b}-wrapper-disabled`]:T.disabled,[`${b}-wrapper-rtl`]:a===`rtl`,[`${b}-wrapper-in-form-item`]:l,[`${b}-wrapper-block`]:!!n?.block},o?.className,f,p,C,w,x),[O,k]=Kt(T.onClick);return S(V.createElement(De,{component:`Radio`,disabled:T.disabled},V.createElement(`label`,{className:D,style:Object.assign(Object.assign({},o?.style),h),onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,title:g,onClick:O},V.createElement(Gt,Object.assign({},T,{className:(0,H.default)(T.className,{[ne]:!y}),type:`radio`,prefixCls:b,ref:c,onClick:k})),m===void 0?null:V.createElement(`span`,{className:`${b}-label`},m))))}),$t=V.forwardRef((e,t)=>{let{getPrefixCls:n,direction:r}=V.useContext(F),{name:i}=V.useContext(Ee),a=be(Qe(i)),{prefixCls:o,className:s,rootClassName:c,options:l,buttonStyle:u=`outline`,disabled:d,children:f,size:p,style:m,id:h,optionType:g,name:_=a,defaultValue:v,value:y,block:b=!1,onChange:x,onMouseEnter:S,onMouseLeave:C,onFocus:w,onBlur:T}=e,[E,D]=Te(v,{value:y}),O=V.useCallback(t=>{let n=E,r=t.target.value;`value`in e||D(r),r!==n&&x?.(t)},[E,D,x]),k=n(`radio`,o),A=`${k}-group`,j=_e(k),[ee,M,te]=Xt(k,j),ne=f;l&&l.length>0&&(ne=l.map(e=>typeof e==`string`||typeof e==`number`?V.createElement(Qt,{key:e.toString(),prefixCls:k,disabled:d,value:e,checked:E===e},e):V.createElement(Qt,{key:`radio-group-value-options-${e.value}`,prefixCls:k,disabled:e.disabled||d,value:e.value,checked:E===e.value,title:e.title,style:e.style,className:e.className,id:e.id,required:e.required},e.label)));let re=fe(p),N=(0,H.default)(A,`${A}-${u}`,{[`${A}-${re}`]:re,[`${A}-rtl`]:r===`rtl`,[`${A}-block`]:b},s,c,M,te,j),ie=V.useMemo(()=>({onChange:O,value:E,disabled:d,name:_,optionType:g,block:b}),[O,E,d,_,g,b]);return ee(V.createElement(`div`,Object.assign({},oe(e,{aria:!0,data:!0}),{className:N,style:m,onMouseEnter:S,onMouseLeave:C,onFocus:w,onBlur:T,id:h,ref:t}),V.createElement(Vt,{value:ie},ne)))}),en=V.memo($t),tn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let{getPrefixCls:n}=V.useContext(F),{prefixCls:r}=e,i=tn(e,[`prefixCls`]),a=n(`radio`,r);return V.createElement(Ut,{value:`button`},V.createElement(Qt,Object.assign({prefixCls:a},i,{type:`radio`,ref:t})))}),rn=Qt;rn.Button=nn,rn.Group=en,rn.__ANT_RADIO=!0;var an=e=>{let{checkboxCls:t}=e,n=`${t}-wrapper`;return[{[`${t}-group`]:Object.assign(Object.assign({},I(e)),{display:`inline-flex`,flexWrap:`wrap`,columnGap:e.marginXS,[`> ${e.antCls}-row`]:{flex:1}}),[n]:Object.assign(Object.assign({},I(e)),{display:`inline-flex`,alignItems:`baseline`,cursor:`pointer`,"&:after":{display:`inline-block`,width:0,overflow:`hidden`,content:`'\\a0'`},[`& + ${n}`]:{marginInlineStart:0},[`&${n}-in-form-item`]:{'input[type="checkbox"]':{width:14,height:14}}}),[t]:Object.assign(Object.assign({},I(e)),{position:`relative`,whiteSpace:`nowrap`,lineHeight:1,cursor:`pointer`,borderRadius:e.borderRadiusSM,alignSelf:`center`,[`${t}-input`]:{position:`absolute`,inset:0,zIndex:1,cursor:`pointer`,opacity:0,margin:0,[`&:focus-visible + ${t}-inner`]:xe(e)},[`${t}-inner`]:{boxSizing:`border-box`,display:`block`,width:e.checkboxSize,height:e.checkboxSize,direction:`ltr`,backgroundColor:e.colorBgContainer,border:`${L(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,borderCollapse:`separate`,transition:`all ${e.motionDurationSlow}`,"&:after":{boxSizing:`border-box`,position:`absolute`,top:`50%`,insetInlineStart:`25%`,display:`table`,width:e.calc(e.checkboxSize).div(14).mul(5).equal(),height:e.calc(e.checkboxSize).div(14).mul(8).equal(),border:`${L(e.lineWidthBold)} solid ${e.colorWhite}`,borderTop:0,borderInlineStart:0,transform:`rotate(45deg) scale(0) translate(-50%,-50%)`,opacity:0,content:`""`,transition:`all ${e.motionDurationFast} ${e.motionEaseInBack}, opacity ${e.motionDurationFast}`}},"& + span":{paddingInlineStart:e.paddingXS,paddingInlineEnd:e.paddingXS}})},{[` ${n}:not(${n}-disabled), ${t}:not(${t}-disabled) `]:{[`&:hover ${t}-inner`]:{borderColor:e.colorPrimary}},[`${n}:not(${n}-disabled)`]:{[`&:hover ${t}-checked:not(${t}-disabled) ${t}-inner`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`},[`&:hover ${t}-checked:not(${t}-disabled):after`]:{borderColor:e.colorPrimaryHover}}},{[`${t}-checked`]:{[`${t}-inner`]:{backgroundColor:e.colorPrimary,borderColor:e.colorPrimary,"&:after":{opacity:1,transform:`rotate(45deg) scale(1) translate(-50%,-50%)`,transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack} ${e.motionDurationFast}`}}},[` ${n}-checked:not(${n}-disabled), ${t}-checked:not(${t}-disabled) `]:{[`&:hover ${t}-inner`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`}}},{[t]:{"&-indeterminate":{"&":{[`${t}-inner`]:{backgroundColor:`${e.colorBgContainer}`,borderColor:`${e.colorBorder}`,"&:after":{top:`50%`,insetInlineStart:`50%`,width:e.calc(e.fontSizeLG).div(2).equal(),height:e.calc(e.fontSizeLG).div(2).equal(),backgroundColor:e.colorPrimary,border:0,transform:`translate(-50%, -50%) scale(1)`,opacity:1,content:`""`}},[`&:hover ${t}-inner`]:{backgroundColor:`${e.colorBgContainer}`,borderColor:`${e.colorPrimary}`}}}}},{[`${n}-disabled`]:{cursor:`not-allowed`},[`${t}-disabled`]:{[`&, ${t}-input`]:{cursor:`not-allowed`,pointerEvents:`none`},[`${t}-inner`]:{background:e.colorBgContainerDisabled,borderColor:e.colorBorder,"&:after":{borderColor:e.colorTextDisabled}},"&:after":{display:`none`},"& + span":{color:e.colorTextDisabled},[`&${t}-indeterminate ${t}-inner::after`]:{background:e.colorTextDisabled}}}]};function on(e,t){return an(Oe(t,{checkboxCls:`.${e}`,checkboxSize:t.controlInteractiveSize}))}var sn=Ae(`Checkbox`,(e,{prefixCls:t})=>[on(t,e)]),cn=V.createContext(null),ln=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let{prefixCls:n,className:r,rootClassName:i,children:a,indeterminate:o=!1,style:s,onMouseEnter:c,onMouseLeave:l,skipGroup:u=!1,disabled:d}=e,f=ln(e,[`prefixCls`,`className`,`rootClassName`,`children`,`indeterminate`,`style`,`onMouseEnter`,`onMouseLeave`,`skipGroup`,`disabled`]),{getPrefixCls:p,direction:m,checkbox:h}=V.useContext(F),g=V.useContext(cn),{isFormItemInput:_}=V.useContext(Ee),v=V.useContext(Ce),y=(g?.disabled||d)??v,b=V.useRef(f.value),x=V.useRef(null),S=we(t,x);V.useEffect(()=>{g?.registerValue(f.value)},[]),V.useEffect(()=>{if(!u)return f.value!==b.current&&(g?.cancelValue(b.current),g?.registerValue(f.value),b.current=f.value),()=>g?.cancelValue(f.value)},[f.value]),V.useEffect(()=>{x.current?.input&&(x.current.input.indeterminate=o)},[o]);let C=p(`checkbox`,n),w=_e(C),[T,E,D]=sn(C,w),O=Object.assign({},f);g&&!u&&(O.onChange=(...e)=>{f.onChange&&f.onChange.apply(f,e),g.toggleOption&&g.toggleOption({label:a,value:f.value})},O.name=g.name,O.checked=g.value.includes(f.value));let k=(0,H.default)(`${C}-wrapper`,{[`${C}-rtl`]:m===`rtl`,[`${C}-wrapper-checked`]:O.checked,[`${C}-wrapper-disabled`]:y,[`${C}-wrapper-in-form-item`]:_},h?.className,r,i,D,w,E),A=(0,H.default)({[`${C}-indeterminate`]:o},ne,E),[j,ee]=Kt(O.onClick);return T(V.createElement(De,{component:`Checkbox`,disabled:y},V.createElement(`label`,{className:k,style:Object.assign(Object.assign({},h?.style),s),onMouseEnter:c,onMouseLeave:l,onClick:j},V.createElement(Gt,Object.assign({},O,{onClick:ee,prefixCls:C,className:A,disabled:y,ref:S})),a!=null&&V.createElement(`span`,{className:`${C}-label`},a))))}),dn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let{defaultValue:n,children:r,options:i=[],prefixCls:a,className:o,rootClassName:s,style:c,onChange:l}=e,u=dn(e,[`defaultValue`,`children`,`options`,`prefixCls`,`className`,`rootClassName`,`style`,`onChange`]),{getPrefixCls:d,direction:f}=V.useContext(F),[p,m]=V.useState(u.value||n||[]),[h,g]=V.useState([]);V.useEffect(()=>{`value`in u&&m(u.value||[])},[u.value]);let _=V.useMemo(()=>i.map(e=>typeof e==`string`||typeof e==`number`?{label:e,value:e}:e),[i]),v=e=>{g(t=>t.filter(t=>t!==e))},y=e=>{g(t=>[].concat(Pe(t),[e]))},b=e=>{let t=p.indexOf(e.value),n=Pe(p);t===-1?n.push(e.value):n.splice(t,1),`value`in u||m(n),l?.(n.filter(e=>h.includes(e)).sort((e,t)=>_.findIndex(t=>t.value===e)-_.findIndex(e=>e.value===t)))},x=d(`checkbox`,a),S=`${x}-group`,C=_e(x),[w,T,E]=sn(x,C),D=le(u,[`value`,`disabled`]),O=i.length?_.map(e=>V.createElement(un,{prefixCls:x,key:e.value.toString(),disabled:`disabled`in e?e.disabled:u.disabled,value:e.value,checked:p.includes(e.value),onChange:e.onChange,className:(0,H.default)(`${S}-item`,e.className),style:e.style,title:e.title,id:e.id,required:e.required},e.label)):r,k=V.useMemo(()=>({toggleOption:b,value:p,disabled:u.disabled,name:u.name,registerValue:y,cancelValue:v}),[b,p,u.disabled,u.name,y,v]),A=(0,H.default)(S,{[`${S}-rtl`]:f===`rtl`},o,s,E,C,T);return w(V.createElement(`div`,Object.assign({className:A,style:c},D,{ref:t}),V.createElement(cn.Provider,{value:k},O)))}),pn=un;pn.Group=fn,pn.__ANT_CHECKBOX=!0;var mn=tt,hn={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM504 618H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM312 490v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8z`}}]},name:`file-text`,theme:`outlined`},gn=V.forwardRef(function(e,t){return V.createElement(ve,P({},e,{ref:t,icon:hn}))}),_n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let{prefixCls:t,className:n,closeIcon:r,closable:i,type:a,title:o,children:d,footer:f}=e,m=_n(e,[`prefixCls`,`className`,`closeIcon`,`closable`,`type`,`title`,`children`,`footer`]),{getPrefixCls:h}=V.useContext(F),g=h(),_=t||h(`modal`),v=_e(g),[y,b,x]=p(_,v),S=`${_}-confirm`,C={};return C=a?{closable:i??!1,title:``,footer:``,children:V.createElement(u,Object.assign({},e,{prefixCls:_,confirmPrefixCls:S,rootPrefixCls:g,content:d}))}:{closable:i??!0,title:o,footer:f!==null&&V.createElement(s,Object.assign({},e)),children:d},y(V.createElement(l,Object.assign({prefixCls:_,className:(0,H.default)(b,`${_}-pure-panel`,a&&S,a&&`${S}-${a}`,n,x,v)},m,{closeIcon:c(_,r),closable:i},C)))});function yn(e){return j(r(e))}var U=d;U.useModal=i,U.info=function(e){return j(f(e))},U.success=function(e){return j(T(e))},U.error=function(e){return j(a(e))},U.warning=yn,U.warn=yn,U.confirm=function(e){return j(o(e))},U.destroyAll=function(){for(;w.length;){let e=w.pop();e&&e()}},U.config=g,U._InternalPanelDoNotUseOrYouWillBeFired=vn;var bn=e=>{let{componentCls:t,iconCls:n,antCls:r,zIndexPopup:i,colorText:a,colorWarning:o,marginXXS:s,marginXS:c,fontSize:l,fontWeightStrong:u,colorTextHeading:d}=e;return{[t]:{zIndex:i,[`&${r}-popover`]:{fontSize:l},[`${t}-message`]:{marginBottom:c,display:`flex`,flexWrap:`nowrap`,alignItems:`start`,[`> ${t}-message-icon ${n}`]:{color:o,fontSize:l,lineHeight:1,marginInlineEnd:c},[`${t}-title`]:{fontWeight:u,color:d,"&:only-child":{fontWeight:`normal`}},[`${t}-description`]:{marginTop:s,color:a}},[`${t}-buttons`]:{textAlign:`end`,whiteSpace:`nowrap`,button:{marginInlineStart:c}}}}},xn=Ae(`Popconfirm`,e=>bn(e),e=>{let{zIndexPopupBase:t}=e;return{zIndexPopup:t+60}},{resetStyle:!1}),Sn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let{prefixCls:t,okButtonProps:n,cancelButtonProps:r,title:i,description:a,cancelText:o,okText:s,okType:c=`primary`,icon:l=V.createElement(Ne,null),showCancel:u=!0,close:d,onConfirm:f,onCancel:p,onPopupClick:h}=e,{getPrefixCls:g}=V.useContext(F),[_]=de(`Popconfirm`,ae.Popconfirm),v=At(i),y=At(a);return V.createElement(`div`,{className:`${t}-inner-content`,onClick:h},V.createElement(`div`,{className:`${t}-message`},l&&V.createElement(`span`,{className:`${t}-message-icon`},l),V.createElement(`div`,{className:`${t}-message-text`},v&&V.createElement(`div`,{className:`${t}-title`},v),y&&V.createElement(`div`,{className:`${t}-description`},y))),V.createElement(`div`,{className:`${t}-buttons`},u&&V.createElement(z,Object.assign({onClick:p,size:`small`},r),o||_?.cancelText),V.createElement(m,{buttonProps:Object.assign(Object.assign({size:`small`},me(c)),n),actionFn:f,close:d,prefixCls:g(`btn`),quitOnNullishReturnValue:!0,emitEvent:!0},s||_?.okText)))},wn=e=>{let{prefixCls:t,placement:n,className:r,style:i}=e,a=Sn(e,[`prefixCls`,`placement`,`className`,`style`]),{getPrefixCls:o}=V.useContext(F),s=o(`popconfirm`,t),[c]=xn(s);return c(V.createElement(Lt,{placement:n,className:(0,H.default)(s,r),style:i,content:V.createElement(Cn,Object.assign({prefixCls:s},a))}))},Tn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i{let{prefixCls:n,placement:r=`top`,trigger:i=`click`,okType:a=`primary`,icon:o=V.createElement(Ne,null),children:s,overlayClassName:c,onOpenChange:l,onVisibleChange:u,overlayStyle:d,styles:f,classNames:p}=e,m=Tn(e,[`prefixCls`,`placement`,`trigger`,`okType`,`icon`,`children`,`overlayClassName`,`onOpenChange`,`onVisibleChange`,`overlayStyle`,`styles`,`classNames`]),{getPrefixCls:h,className:g,style:_,classNames:v,styles:y}=ge(`popconfirm`),[b,x]=Te(!1,{value:e.open??e.visible,defaultValue:e.defaultOpen??e.defaultVisible}),S=(e,t)=>{x(e,!0),u?.(e),l?.(e,t)},C=e=>{S(!1,e)},w=t=>e.onConfirm?.call(void 0,t),T=t=>{var n;S(!1,t),(n=e.onCancel)==null||n.call(void 0,t)},E=(t,n)=>{let{disabled:r=!1}=e;r||S(t,n)},D=h(`popconfirm`,n),O=(0,H.default)(D,g,c,v.root,p?.root),k=(0,H.default)(v.body,p?.body),[A]=xn(D);return A(V.createElement(zt,Object.assign({},le(m,[`title`]),{trigger:i,placement:r,onOpenChange:E,open:b,ref:t,classNames:{root:O,body:k},styles:{root:Object.assign(Object.assign(Object.assign(Object.assign({},y.root),_),d),f?.root),body:Object.assign(Object.assign({},y.body),f?.body)},content:V.createElement(Cn,Object.assign({okType:a,icon:o},e,{prefixCls:D,close:C,onConfirm:w,onCancel:T})),"data-popover-inject":!0}),s))});En._InternalPanelDoNotUseOrYouWillBeFired=wn;var W=rt,Dn={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z`}}]},name:`delete`,theme:`outlined`},On=V.forwardRef(function(e,t){return V.createElement(ve,P({},e,{ref:t,icon:Dn}))}),kn={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M899.1 869.6l-53-305.6H864c14.4 0 26-11.6 26-26V346c0-14.4-11.6-26-26-26H618V138c0-14.4-11.6-26-26-26H432c-14.4 0-26 11.6-26 26v182H160c-14.4 0-26 11.6-26 26v192c0 14.4 11.6 26 26 26h17.9l-53 305.6a25.95 25.95 0 0025.6 30.4h723c1.5 0 3-.1 4.4-.4a25.88 25.88 0 0021.2-30zM204 390h272V182h72v208h272v104H204V390zm468 440V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H416V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H202.8l45.1-260H776l45.1 260H672z`}}]},name:`clear`,theme:`outlined`},An=V.forwardRef(function(e,t){return V.createElement(ve,P({},e,{ref:t,icon:kn}))}),jn={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M811.4 368.9C765.6 248 648.9 162 512.2 162S258.8 247.9 213 368.8C126.9 391.5 63.5 470.2 64 563.6 64.6 668 145.6 752.9 247.6 762c4.7.4 8.7-3.3 8.7-8v-60.4c0-4-3-7.4-7-7.9-27-3.4-52.5-15.2-72.1-34.5-24-23.5-37.2-55.1-37.2-88.6 0-28 9.1-54.4 26.2-76.4 16.7-21.4 40.2-36.9 66.1-43.7l37.9-10 13.9-36.7c8.6-22.8 20.6-44.2 35.7-63.5 14.9-19.2 32.6-36 52.4-50 41.1-28.9 89.5-44.2 140-44.2s98.9 15.3 140 44.3c19.9 14 37.5 30.8 52.4 50 15.1 19.3 27.1 40.7 35.7 63.5l13.8 36.6 37.8 10c54.2 14.4 92.1 63.7 92.1 120 0 33.6-13.2 65.1-37.2 88.6-19.5 19.2-44.9 31.1-71.9 34.5-4 .5-6.9 3.9-6.9 7.9V754c0 4.7 4.1 8.4 8.8 8 101.7-9.2 182.5-94 183.2-198.2.6-93.4-62.7-172.1-148.6-194.9z`}},{tag:`path`,attrs:{d:`M376.9 656.4c1.8-33.5 15.7-64.7 39.5-88.6 25.4-25.5 60-39.8 96-39.8 36.2 0 70.3 14.1 96 39.8 1.4 1.4 2.7 2.8 4.1 4.3l-25 19.6a8 8 0 003 14.1l98.2 24c5 1.2 9.9-2.6 9.9-7.7l.5-101.3c0-6.7-7.6-10.5-12.9-6.3L663 532.7c-36.6-42-90.4-68.6-150.5-68.6-107.4 0-195 85.1-199.4 191.7-.2 4.5 3.4 8.3 8 8.3H369c4.2-.1 7.7-3.4 7.9-7.7zM703 664h-47.9c-4.2 0-7.7 3.3-8 7.6-1.8 33.5-15.7 64.7-39.5 88.6-25.4 25.5-60 39.8-96 39.8-36.2 0-70.3-14.1-96-39.8-1.4-1.4-2.7-2.8-4.1-4.3l25-19.6a8 8 0 00-3-14.1l-98.2-24c-5-1.2-9.9 2.6-9.9 7.7l-.4 101.4c0 6.7 7.6 10.5 12.9 6.3l23.2-18.2c36.6 42 90.4 68.6 150.5 68.6 107.4 0 195-85.1 199.4-191.7.2-4.5-3.4-8.3-8-8.3z`}}]},name:`cloud-sync`,theme:`outlined`},Mn=V.forwardRef(function(e,t){return V.createElement(ve,P({},e,{ref:t,icon:jn}))}),Nn={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M820 436h-40c-4.4 0-8 3.6-8 8v40c0 4.4 3.6 8 8 8h40c4.4 0 8-3.6 8-8v-40c0-4.4-3.6-8-8-8zm32-104H732V120c0-4.4-3.6-8-8-8H300c-4.4 0-8 3.6-8 8v212H172c-44.2 0-80 35.8-80 80v328c0 17.7 14.3 32 32 32h168v132c0 4.4 3.6 8 8 8h424c4.4 0 8-3.6 8-8V772h168c17.7 0 32-14.3 32-32V412c0-44.2-35.8-80-80-80zM360 180h304v152H360V180zm304 664H360V568h304v276zm200-140H732V500H292v204H160V412c0-6.6 5.4-12 12-12h680c6.6 0 12 5.4 12 12v292z`}}]},name:`printer`,theme:`outlined`},Pn=V.forwardRef(function(e,t){return V.createElement(ve,P({},e,{ref:t,icon:Nn}))}),G=n();function Fn({children:e,label:t=`查看说明`}){return(0,G.jsx)(Ke,{title:e,trigger:[`hover`,`focus`,`click`],placement:`top`,children:(0,G.jsx)(`span`,{className:`help-icon`,role:`button`,tabIndex:0,"aria-label":t,children:(0,G.jsx)(nt,{})})})}function In(){return(0,G.jsxs)(`span`,{className:`internal-tag`,children:[(0,G.jsx)(it,{"aria-hidden":`true`}),` 内部 · 客户不可见`]})}function Ln({label:e,field:t,hint:n,help:r,hidden:i,className:a,span:o,id:s,labelId:c,children:l}){if(i)return null;let u=(0,G.jsxs)(`div`,{className:`field `+(a||``),"data-field":t,children:[(0,G.jsxs)(`div`,{className:`field-label-row`,children:[(0,G.jsx)(`label`,{className:`field-label`,htmlFor:s,id:c,children:e}),r?(0,G.jsx)(Fn,{children:r}):null]}),l,n?(0,G.jsx)(`div`,{className:`field-hint`,children:n}):null]});return o?(0,G.jsx)(mn,{...o,children:u}):u}var Rn=e=>typeof e.label==`string`?e.label:e.field;function K({value:e,onChange:t,numeric:n,readOnly:r,disabled:i,placeholder:a,maxLength:o,type:s,...c}){let l=(0,V.useId)();return(0,G.jsx)(Ln,{...c,id:l,children:(0,G.jsx)(ct,{id:l,name:c.field,"aria-label":Rn(c),value:e,type:s,inputMode:n?`decimal`:void 0,autoComplete:`off`,readOnly:r,disabled:i,placeholder:a,maxLength:o,className:(r?`readonly-input`:``)+(n?` num`:``),onChange:e=>t?.(e.target.value)})})}function q({value:e,options:t,onChange:n,disabled:r,placeholder:i,...a}){let o=(0,V.useId)();return(0,G.jsx)(Ln,{...a,id:o,children:(0,G.jsx)(at,{id:o,"aria-label":Rn(a),value:e===``&&i?void 0:e,placeholder:i,disabled:r,popupMatchSelectWidth:!1,options:t.map(([e,t,n])=>({value:e,label:t,disabled:!!n,title:t})),onChange:n,getPopupContainer:()=>document.body})})}function J({value:e,options:t,onChange:n,disabled:r,...i}){let a=(0,V.useId)();return(0,G.jsx)(Ln,{...i,labelId:a,children:(0,G.jsx)(rn.Group,{value:e,disabled:r,optionType:`button`,buttonStyle:`solid`,block:!0,role:`radiogroup`,"aria-labelledby":a,onChange:e=>n(e.target.value),options:t.map(([e,t,n])=>({value:e,label:t,disabled:!!n}))})})}var Y={xs:24,sm:12,xl:6},X={xs:12,sm:12,xl:6},Z={xs:24,sm:12,xl:8},zn={xs:24,md:12};function Bn({id:e,step:t,title:n,help:r,extra:i,internal:a,className:o,testId:s,children:c}){return(0,G.jsx)(ot,{id:e,className:`panel`+(a?` panel-internal`:``)+(o?` `+o:``),"data-testid":s,title:(0,G.jsxs)(`div`,{className:`section-title`,children:[(0,G.jsx)(`span`,{className:`step-no`,"aria-hidden":`true`,children:t}),(0,G.jsx)(`h2`,{children:n}),r?(0,G.jsx)(Fn,{label:`关于`+(typeof n==`string`?n:`本区`),children:r}):null,a?(0,G.jsx)(In,{}):null]}),extra:i,children:c})}function Vn({form:e,state:t,paperNumber:n,update:r}){let i=e=>t=>r(n=>({...n,[e]:t})),a=B.teamMode(t),o=e.payment.method===`信用卡`;return(0,G.jsx)(Bn,{id:`section-customer`,step:`01`,title:`客户与单据`,help:`生成单据即按成交合计记录全额收款,同时按所选货盘扣减黄金库存并计入实际利润。请核对商品已交付,选择实际收款方式与收款人;业务日期作为收款和出库日期。`,extra:(0,G.jsxs)(`span`,{className:`section-extra`,children:[(0,G.jsx)(Mn,{"aria-hidden":`true`}),` `,e.id?`补齐原草稿,生成销售单据后完成记账`:`填写内容自动暂存,生成单据即完成记账`]}),children:(0,G.jsxs)(W,{gutter:[16,14],children:[(0,G.jsx)(K,{span:X,label:`业务日期`,field:`date`,type:`date`,value:e.date,onChange:i(`date`)}),(0,G.jsx)(K,{span:X,label:`纸单编号(自动)`,field:`paper_number`,value:n,readOnly:!0,help:`前半段为业务日期,后半段序号持续累计,中间不加横线,换日期不归零;生成时分配。`}),(0,G.jsx)(K,{span:Y,label:`客户称呼/代号(必填)`,field:`customer`,value:e.customer,maxLength:60,placeholder:`方便找回订单即可`,onChange:i(`customer`)}),(0,G.jsx)(J,{span:Y,label:`客户类型`+(e.customerTypeRequired?`(必选)`:``),field:`customer_type`,value:e.customer_type,options:[[`new`,`新客户`],[`returning`,`老客户`]],onChange:i(`customer_type`)}),(0,G.jsx)(K,{span:X,label:`开单人(必填)`,field:`salesperson`,value:e.salesperson,maxLength:30,onChange:i(`salesperson`)}),a&&(e.memberLocked?(0,G.jsx)(K,{span:X,label:`订单归属(经营款与业绩)`,field:`member`,value:B.memberName(t,e.member),readOnly:!0}):(0,G.jsx)(q,{span:X,label:`订单归属(经营款与业绩)`,field:`member`,value:e.member,options:B.memberOptions(t),onChange:e=>r(n=>B.changeMember(n,e,t))})),(0,G.jsx)(J,{span:Y,label:`收款方式`,field:`payment_method`,value:e.payment.method,options:B.paymentMethods(t).map(e=>[e,e]),onChange:e=>r(t=>({...t,payment:{...t.payment,method:e}}))}),(0,G.jsx)(q,{span:Y,label:`收款人`,field:`payment_recipient`,value:e.payment.recipient,disabled:o,options:B.recipientOptions(t,e.payment),hint:o&&B.creditCardAvailable(t)?`信用卡统一由${B.memberName(t,`owner`)}收款。`:void 0,onChange:e=>r(t=>({...t,payment:{...t.payment,recipient:e}}))})]})})}function Hn(e,t,n){if(!e.purchase||!e.pool)throw Error(`旧版未分项成本请先拆分,再选择退回现货。`);let r=e.returnedStockOriginal??{nameType:e.nameType,customName:e.customName,unit:e.unit,quantity:e.quantity,pocket:e.pocket,stockCount:e.stockCount,purchase:e.purchase,pool:e.pool},i=t.effectivePoolId||n,a=B.productNames.includes(t.name)?t.name:`其他`;return{...e,returnedStockId:t.id,returnedStockCode:t.code||``,returnedStockLot:t,returnedStockOriginal:r,nameType:a,customName:a===`其他`?t.name:``,unit:`g`,quantity:D(t.remainingMg),pocket:t.pocket,stockCount:String(t.remainingCount??t.stockCount??``),purchase:{...e.purchase,laborMode:`total`,laborRate:``,labor:(t.laborCost/100).toFixed(2),laborPayer:t.laborPayer},pool:{...e.pool,poolId:i,dataPoolId:i,source:`pool`,preferredSource:`pool`,defaultDate:!1}}}function Un(e){let t=e.returnedStockOriginal,n={...e};if(delete n.returnedStockId,delete n.returnedStockCode,delete n.returnedStockLot,delete n.returnedStockOriginal,!t||!n.purchase||!n.pool)return n;let{purchase:r,pool:i,...a}=t;return{...n,...a,purchase:{...n.purchase,laborMode:r.laborMode,laborRate:r.laborRate,labor:r.labor,laborPayer:r.laborPayer},pool:{...n.pool,poolId:i.poolId,dataPoolId:i.dataPoolId,source:i.source,defaultDate:i.defaultDate,preferredSource:i.preferredSource}}}function Wn(e,t,n,r){let[i,a]=(0,V.useState)(0),[o,s]=(0,V.useState)(null),c=t.date,l=t.member||B.currentMember(n),u=`/api/returned-stock-lots?`+new URLSearchParams({member:l,date:c});(0,V.useEffect)(()=>{if(!e)return;let t=!0;async function i(){try{let i=await e.api(u);if(!Array.isArray(i?.lots)||i.lots.some(e=>typeof e.id!=`string`||!Number.isSafeInteger(e.remainingMg)||!Number.isSafeInteger(e.laborCost)||!B.memberKeys(n).includes(e.laborPayer)))throw Error(`售后退回现货列表未完整返回。`);if(!t)return;s(null),r(e=>({...e,returnedLots:{member:l,date:c,lots:i.lots},lines:e.lines.map(e=>{let t=e.returnedStockId&&i.lots.find(t=>t.id===e.returnedStockId&&B.canUseReturnedLot(t,n,c));return t&&!e.legacy?Hn(e,t,c):e})}))}catch(e){t&&(s({url:u,message:e.message}),r(e=>({...e,returnedLots:void 0})))}}return i(),()=>{t=!1}},[e,u,c,l,n,r,i]);let d=(0,V.useCallback)(()=>a(e=>e+1),[]);return{error:o?.url===u?o.message:``,reload:d}}function Gn({form:e,index:t,state:n,update:r,error:i,reload:a,onError:o}){let s=e.lines[t],c=e.returnedLots,l=c?.date===e.date&&c.member===(e.member||B.currentMember(n))?c.lots.filter(t=>B.canUseReturnedLot(t,n,e.date)):[],u=l.find(e=>e.id===s.returnedStockId),d=new Set(e.lines.filter((e,n)=>n!==t).map(e=>e.returnedStockId));function f(e){try{if(!e)return r(e=>B.updateLine(e,t,Un(e.lines[t])));let n=l.find(t=>t.id===e);if(!n)throw Error(`这件退回现货已不可用,请刷新页面后重新核对。`);if(d.has(e))throw Error(`同一件售后退回现货不能重复开单。`);r(e=>B.updateLine(e,t,Hn(e.lines[t],n,e.date)))}catch(e){o(e.message)}}return(0,G.jsxs)(`div`,{className:`returned-stock-choice`,"data-returned-stock-choice":!0,hidden:!i&&!l.length&&!s.returnedStockId,children:[(0,G.jsxs)(`label`,{children:[`售后退回现货(已有工费)`,(0,G.jsxs)(`select`,{name:`returnedStockId`,value:s.returnedStockId||``,onChange:e=>f(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`普通现货/本次新采购`}),l.map(e=>(0,G.jsxs)(`option`,{value:e.id,disabled:d.has(e.id),children:[e.date,` · `,e.name,` · `,D(e.remainingMg),`g`,e.remainingCount!=null&&` · `+e.remainingCount+`对`,` `,`· 已有工费 ¥`,v(e.laborCost)]},e.id)),s.returnedStockId&&!u&&(0,G.jsx)(`option`,{disabled:!0,value:s.returnedStockId,children:`原退回现货已无可用库存,请重新选择`})]})]}),(0,G.jsx)(`p`,{"data-returned-stock-note":!0,children:i?i+` 如本次销售售后退回现货,请刷新列表后选择对应批次。`:u?`本件已有进货工费 ¥`+v(u.laborCost)+`,沿用`+B.memberName(n,u.laborPayer)+`原付款来源,不新增付款。按原克重整批出库。`+(u.materialPoolNotice||`料费按本单使用的料池计算。`):`选择对应退回现货后,沿用原工费和付款来源,不重复登记工费付款。`}),(0,G.jsx)(z,{"data-action":`order-after-sale-reload-stock`,onClick:a,children:`刷新退回现货`})]})}function Kn({index:e,line:t,update:n}){let r=(t,r)=>n(n=>{let i=n.lines[e];return B.updateLine(n,e,{...i,charges:i.charges.map((e,n)=>n===t?r(e):e)})});return(0,G.jsxs)(`div`,{className:`sale-charges`,children:[(0,G.jsxs)(`div`,{className:`sub-title`,children:[(0,G.jsxs)(`div`,{className:`sub-title-text`,children:[(0,G.jsx)(`strong`,{children:`工费附加项目`}),(0,G.jsx)(`span`,{className:`small muted`,children:`选填 · 编绳、证书、包装、快递`}),(0,G.jsx)(Fn,{label:`关于工费附加项目`,children:`向客户收费预填:编绳55元、证书10元、包装10元、快递8元,均可修改;按填写金额自动加进本行销售额。`})]}),(0,G.jsx)(z,{size:`small`,icon:(0,G.jsx)(st,{}),"data-action":`add-charge`,onClick:()=>n(t=>B.addCharge(t,e,Xe)),children:`添加附加项目`})]}),t.charges.length>0&&(0,G.jsx)(`div`,{className:`charge-list`,children:t.charges.map((t,i)=>(0,G.jsxs)(`div`,{className:`charge-row`,"data-charge":i,children:[(0,G.jsx)(q,{label:`附加项目`,field:`chargeType`,value:t.type,options:[...B.chargeNames,`其他`].map(e=>[e,e]),onChange:e=>r(i,t=>B.changeChargeType(t,e))}),(0,G.jsx)(K,{label:`附加项目名称`,field:`chargeName`,hidden:t.type!==`其他`,value:t.customName,maxLength:40,onChange:e=>r(i,t=>({...t,customName:e}))}),(0,G.jsx)(K,{label:`附加金额(元)`,field:`chargeAmount`,numeric:!0,value:t.amount,placeholder:`没有收费填0,可修改金额`,onChange:e=>r(i,t=>B.setChargeAmount(t,e))}),(0,G.jsxs)(`div`,{className:`charge-actions`,children:[(0,G.jsx)(z,{type:`text`,size:`small`,icon:(0,G.jsx)(ce,{}),"data-action":`remove-charge`,onClick:()=>n(t=>{let n=t.lines[e];return B.updateLine(t,e,{...n,charges:n.charges.filter((e,t)=>t!==i)})}),children:`移除附加项`}),t.costRemoved&&(0,G.jsxs)(`small`,{className:`muted`,children:[`内部成本已移除`,` `,(0,G.jsx)(z,{type:`link`,size:`small`,"data-action":`restore-charge-cost`,onClick:()=>n(t=>B.restoreChargeCost(t,e,i)),children:`恢复内部成本`})]})]})]},t.id))})]})}function qn({index:e,line:t,state:n,update:r,onReloadPools:i}){let a=B.lineVisibility(t,n),o=t=>r(n=>B.updateLine(n,e,t(n.lines[e]))),s=e=>t=>o(n=>B.setPurchaseField(n,e,t)),c=B.memberOptions(n),l=t.purchase,u=t.pool?.source===`pool`,d=e=>B.memberKeys(n).includes(e)?B.memberOptions(n,!1,{selected:e}):c;return(0,G.jsxs)(`div`,{className:`internal`,children:[(0,G.jsxs)(`div`,{className:`internal-title`,children:[(0,G.jsx)(it,{"aria-hidden":`true`}),(0,G.jsx)(`strong`,{children:`内部成本`}),(0,G.jsx)(`span`,{className:`internal-tag`,children:`内部 · 客户不可见`})]}),(0,G.jsxs)(W,{gutter:[16,14],className:`cost-source-fields`,children:[(0,G.jsx)(q,{span:Z,label:`出库货盘(仅黄金)`,field:`pocket`,disabled:!!t.returnedStockLot,value:t.pocket,options:B.pocketOptions(n,t.pocket,t.historicalPocket),onChange:e=>o(t=>B.setLineField(t,`pocket`,e))}),(0,G.jsx)(K,{span:Z,label:`出库数量(对)`,field:`stockCount`,readOnly:!!t.returnedStockLot,numeric:!0,hidden:!a.stockCount,value:t.stockCount,placeholder:`一对填1`,hint:a.stockCountOptional?`历史未记录对数,可保留空白;与计工费件数分别填写。`:`与计工费件数分别填写。`,onChange:e=>o(t=>B.setLineField(t,`stockCount`,e))})]}),t.legacy?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{field:`payer`,label:`货品成本由谁垫付`,value:t.payer,options:d(t.payer),onChange:e=>o(t=>({...t,payer:e}))}),(0,G.jsx)(K,{label:`原单货品成本(旧版未分项)`,field:`cost`,numeric:!0,value:t.cost,readOnly:!0}),(0,G.jsxs)(`div`,{className:`legacy-cost-note small`,children:[`保留原金额,拆分时请根据凭据填写。`,(0,G.jsx)(z,{"data-action":`split-cost`,onClick:()=>{o(e=>{let t=B.newLine({unit:e.unit,payer:e.payer,costParts:{material:``,labor:``,accessories:`0`,other:`0`},costMaterial:{mode:e.unit===`g`?`gram`:`total`}},{st:n,uuid:Xe});return{...e,legacy:!1,cost:``,purchase:t.purchase,pool:t.pool}}),i()},children:`拆分这行成本`})]})]}):l&&(0,G.jsxs)(`div`,{className:`cost-fields`,children:[t.pool&&(0,G.jsxs)(`div`,{className:`material-source`,children:[(0,G.jsxs)(W,{gutter:[16,14],children:[(0,G.jsx)(J,{span:Z,label:`料费成本来源`,help:t.pool.help,field:`materialSource`,disabled:!!t.returnedStockLot,value:t.pool.source,options:[[`manual`,`手动填写成本`],[`pool`,`当日加权料价`,!a.poolAllowed]],onChange:e=>o(t=>B.setPoolSource(t,e))}),u&&(0,G.jsx)(q,{span:Z,label:`料价日期`,field:`materialPoolId`,disabled:!!t.returnedStockLot,value:t.pool.poolId,options:t.pool.options.map(e=>[e.value,e.label]),onChange:e=>o(t=>({...t,pool:t.pool?{...t.pool,poolId:e}:t.pool}))}),u&&(0,G.jsx)(Ln,{span:Z,label:`\xA0`,field:`reload-material-choices`,children:(0,G.jsx)(z,{icon:(0,G.jsx)(ut,{}),"data-action":`reload-material-choices`,onClick:i,className:`reload-button`,children:`刷新料价`})})]}),u&&t.view.poolNote&&(0,G.jsx)(`p`,{className:`small material-pool-note`,"aria-live":`polite`,"data-testid":`pool-note`,children:t.view.poolNote})]}),(0,G.jsxs)(W,{gutter:[16,14],className:`purchase-cost-grid`,children:[a.materialMode&&(0,G.jsx)(J,{span:Y,label:`进货料费方式`,field:`cost-materialMode`,value:l.materialMode,options:[[`gram`,`按克料价`,t.unit!==`g`],[`total`,`直接填总料费`]],onChange:s(`materialMode`)}),(0,G.jsx)(K,{span:X,label:u?`加权进货料价(元/克,自动)`:`进货料价(元/克)`,field:`cost-materialRate`,numeric:!0,hidden:!a.materialRate,readOnly:u,value:l.materialRate,placeholder:u?`待核算`:`填写每克进货料价`,onChange:s(`materialRate`)}),(0,G.jsx)(K,{span:X,label:u?`耗用料费合计(元,自动)`:`料费成本合计(元)`,field:`cost-material`,numeric:!0,readOnly:a.materialReadOnly,value:l.material,placeholder:u?`待核算`:`开单前必填,没有填0`,onChange:s(`material`)}),a.materialPayer?(0,G.jsx)(q,{span:Y,label:`料费付款人`,field:`cost-materialPayer`,value:l.materialPayer,placeholder:`请选择`,options:d(l.materialPayer),onChange:s(`materialPayer`)}):(0,G.jsx)(K,{span:Y,label:t.pool?.personal?`材料原付款人`:`本批购料付款人`,field:`cost-materialPoolPayer`,value:t.pool?.payerText||``,readOnly:!0})]}),(0,G.jsx)(`p`,{className:`purchase-formula small muted`,"aria-live":`polite`,children:t.view.materialFormula}),t.view.materialOriginal&&(0,G.jsx)(`p`,{className:`small muted`,children:t.view.materialOriginal}),(0,G.jsxs)(W,{gutter:[16,14],className:`purchase-cost-grid`,children:[(0,G.jsx)(J,{span:Y,label:`进货工费方式`,field:`cost-laborMode`,disabled:!!t.returnedStockLot,value:l.laborMode,options:[[`gram`,`克工费`,t.unit!==`g`],[`total`,`总工费`]],onChange:s(`laborMode`)}),(0,G.jsx)(K,{span:X,label:`进货克工费(元/克)`,field:`cost-laborRate`,readOnly:!!t.returnedStockLot,numeric:!0,hidden:!a.laborRateInput,value:l.laborRate,placeholder:`填写每克工费`,onChange:s(`laborRate`)}),(0,G.jsx)(K,{span:X,label:`进货总工费(元)`,field:`cost-labor`,numeric:!0,readOnly:a.laborReadOnly||!!t.returnedStockLot,value:l.labor,placeholder:`开单前必填,没有填0`,onChange:s(`labor`)}),(0,G.jsx)(q,{span:Y,label:`进货工费付款人`,field:`cost-laborPayer`,disabled:!!t.returnedStockLot,value:l.laborPayer,placeholder:`请选择`,options:d(l.laborPayer),onChange:s(`laborPayer`)})]}),(0,G.jsx)(`p`,{className:`purchase-formula small muted`,"aria-live":`polite`,children:t.view.laborFormula}),a.extraCosts&&(0,G.jsxs)(`div`,{className:`legacy-extra-costs`,children:[(0,G.jsx)(`p`,{className:`small muted`,children:`这里保留原来填写的货品成本,不要在下方实际费用重复登记。`}),(0,G.jsxs)(W,{gutter:[16,14],children:[(0,G.jsx)(K,{span:Z,label:`配件成本(元,本行合计)`,field:`cost-accessories`,numeric:!0,value:l.accessories,onChange:s(`accessories`)}),(0,G.jsx)(K,{span:Z,label:`其他货品成本(元,本行合计)`,field:`cost-other`,numeric:!0,value:l.other,onChange:s(`other`)}),(0,G.jsx)(q,{span:Z,label:`原有配件及其他成本付款人`,field:`payer`,value:t.payer,options:c,onChange:e=>o(t=>({...t,payer:e}))})]})]}),(0,G.jsxs)(`p`,{className:`cost-summary`,children:[(0,G.jsx)(`span`,{children:`本行货品成本合计`}),(0,G.jsx)(`span`,{className:`num`+(t.view.purchase?.total==null?` pending`:``),children:t.view.purchase?.total==null?u?`料费待核算`:`请补齐(没有的项目填0)`:`¥`+B.yuan(t.view.purchase.total)})]})]})]})}var Jn={xs:24,sm:12,xl:8},Yn={xs:12,sm:12,xl:4};function Xn({client:e,form:t,state:n,update:r,onError:i,onReloadPools:a}){let o=Wn(e,t,n,r),s=e=>{try{r(e)}catch(e){i(e.message)}};return(0,G.jsxs)(Bn,{id:`section-lines`,step:`02`,title:`商品明细`,help:`金价与工费分开填写。银饰不扣黄金货盘;外配使用店内金料时,选实际出库货盘。`,extra:(0,G.jsxs)(`span`,{className:`section-extra`,children:[`共 `,t.lines.length,` 件商品`]}),children:[t.lines.map((c,l)=>(0,G.jsx)(Zn,{index:l,returnedStockChoice:e&&!c.historicalPocket&&(0,G.jsx)(Gn,{form:t,index:l,update:r,state:n,error:o.error,reload:o.reload,onError:i}),line:c,state:n,canRemove:t.lines.length>1,update:r,onRemove:()=>{if(t.lines.length<=1)return i(`请至少保留一行商品`);s(e=>B.removeLine(e,l))},onReloadPools:a},l)),(0,G.jsxs)(`div`,{className:`form-actions`,children:[(0,G.jsx)(z,{className:`add-line-button`,icon:(0,G.jsx)(st,{}),"data-action":`add-line`,onClick:()=>{let e=t.lines.length;s(e=>B.addLine(e,{st:n,uuid:Xe})),window.requestAnimationFrame(()=>{document.querySelector(`[data-line="${e}"]`)?.scrollIntoView?.({behavior:`smooth`,block:`nearest`})})},children:`添加商品`}),(0,G.jsx)(`span`,{className:`small muted`,children:`银饰不扣黄金货盘;外配用店内金料时选实际出库货盘。`})]})]})}function Zn({returnedStockChoice:e,index:t,line:n,state:r,canRemove:i,update:a,onRemove:o,onReloadPools:s}){let c=B.lineVisibility(n,r),l=e=>a(n=>B.updateLine(n,t,e(n.lines[t]))),u=e=>t=>l(n=>B.setLineField(n,e,t));return(0,G.jsxs)(`section`,{className:`line-item`,"data-line":t,"aria-label":`商品 `+(t+1),children:[(0,G.jsxs)(`div`,{className:`line-top`,children:[(0,G.jsxs)(`div`,{className:`line-heading`,children:[(0,G.jsx)(`span`,{className:`line-no`,children:String(t+1).padStart(2,`0`)}),(0,G.jsxs)(`strong`,{children:[`商品 `,String(t+1).padStart(2,`0`)]}),(0,G.jsx)(`span`,{className:`line-name muted`,children:n.nameType===`其他`?n.customName:n.nameType})]}),(0,G.jsxs)(`div`,{className:`line-top-right`,children:[n.sale&&(0,G.jsxs)(`span`,{className:`line-subtotal-chip num`,children:[n.quantity?(0,G.jsxs)(`span`,{className:`line-qty-meta`,children:[n.quantity,n.unit]}):null,(0,G.jsxs)(`span`,{children:[`¥`,n.sale]})]}),(0,G.jsx)(z,{type:`text`,size:`small`,icon:(0,G.jsx)(On,{}),"data-action":`remove-line`,disabled:!i,onClick:o,children:`移除`})]})]}),e,(0,G.jsxs)(W,{gutter:[16,14],children:[(0,G.jsx)(q,{span:Y,label:`商品名称`,field:`nameType`,disabled:!!n.returnedStockLot,value:n.nameType,options:[...B.productNames,`其他`].map(e=>[e,e]),onChange:u(`nameType`)}),(0,G.jsx)(K,{span:Y,label:`其他商品名称`,field:`customName`,readOnly:!!n.returnedStockLot,hidden:!c.customName,value:n.customName,maxLength:60,onChange:u(`customName`)}),(0,G.jsx)(J,{span:Jn,label:`计价方式`,field:`pricingMode`,value:n.pricingMode,options:[[`auto`,`按金价与工费计算`],[`manual`,`直接填写金额`]],onChange:u(`pricingMode`)}),(0,G.jsx)(J,{span:Yn,label:`单位`,field:`unit`,disabled:!!n.returnedStockLot,value:n.unit,options:[[`g`,`g`],[`件`,`件`]],onChange:u(`unit`)}),(0,G.jsx)(K,{span:X,label:`克重/数量`,field:`quantity`,readOnly:!!n.returnedStockLot,numeric:!0,value:n.quantity,onChange:u(`quantity`)})]}),(0,G.jsxs)(W,{gutter:[16,14],className:`sale-inputs`,children:[(0,G.jsx)(K,{span:X,label:`金价/银价(元/克)`,field:`goldPrice`,numeric:!0,hidden:!c.goldPrice,value:n.goldPrice,onChange:u(`goldPrice`)}),(0,G.jsx)(J,{span:X,label:`销售工费方式`,field:`laborMode`,hidden:!c.laborMode,value:n.laborMode,options:[[`gram`,`克工费`],[`piece`,`件工费`]],onChange:u(`laborMode`)}),(0,G.jsx)(K,{span:X,label:`销售工费`,field:`laborRate`,numeric:!0,hidden:!c.laborRate,value:n.laborRate,onChange:u(`laborRate`)}),(0,G.jsx)(K,{span:X,label:`计工费件数`,field:`pieces`,numeric:!0,hidden:!c.pieces,value:n.pieces,onChange:u(`pieces`)}),(0,G.jsx)(K,{span:zn,label:`销售单价说明(客户可见)`,field:`priceNote`,hidden:!c.priceNote,value:n.priceNote,maxLength:100,onChange:u(`priceNote`)}),(0,G.jsx)(K,{span:Y,label:`商品基础金额(不含附加项目)`,field:`baseSale`,numeric:!0,hidden:!c.baseSale,value:n.baseSale,onChange:u(`baseSale`)})]}),(0,G.jsx)(Kn,{index:t,line:n,update:a}),(0,G.jsxs)(W,{gutter:[16,8],className:`sale-result`,align:`bottom`,children:[(0,G.jsx)(K,{span:{xs:24,md:10,xl:8},className:`sale-field`,label:`本行销售额(元,含附加项目)`,field:`sale`,value:n.sale,readOnly:!0}),(0,G.jsx)(mn,{xs:24,md:14,xl:16,children:(0,G.jsx)(Ge.Paragraph,{className:`calculation small`,"aria-live":`polite`,"data-testid":`line-calculation`,children:n.view.calculation})})]}),(0,G.jsx)(qn,{index:t,line:n,state:r,update:a,onReloadPools:s})]})}function Qn({form:e,state:t,summary:n,update:r}){let i=e.presets,a=B.presetCatalogView(e,t),o={certificate:`4`,packaging:`3`,shipping:`6`,...t.shopSettings?.feeDefaults},s=i?`按实际发生勾选,快递最多选一项;盒子按配置单价和数量计费。取消勾选不记成本,客户收费不受影响。`:e.feeCostMode===`checkboxes`?`沿用本单已有费用、付款人与支付日期。普通费用按凭据核对;信用卡手续费金额和日期自动维护。`:`上方附加项目自动带入成本。证书默认${o.certificate}元、包装${o.packaging}元;快递按整单默认${o.shipping}元,均可修改。请填写实际已付金额,没有成本填0;不需要的整单费用可移除。开单时记录费用和付款人。`;return(0,G.jsxs)(Bn,{id:`section-fees`,step:`03`,title:`实际费用`,internal:!0,testId:`fee-costs`,help:s+` 客户单据不显示。`,extra:(0,G.jsx)(z,{size:`small`,icon:(0,G.jsx)(st,{}),"data-action":`add-fee`,onClick:()=>{r(e=>B.addManualFee(e,t,Xe)),window.requestAnimationFrame(()=>{let e=document.querySelectorAll(`.fee-row [data-field="feeNote"] input`),t=e[e.length-1];t?.scrollIntoView?.({behavior:`smooth`,block:`nearest`}),t?.focus?.({preventScroll:!0})})},children:`添加其他成本`}),children:[!i&&(0,G.jsx)(`p`,{className:`small muted section-lead`,children:s}),(0,G.jsx)(W,{gutter:[16,14],children:(0,G.jsx)(K,{span:Y,label:`费用实际支付日期`,field:`fees_date`,type:`date`,value:e.fees_date,onChange:e=>r(t=>({...t,fees_date:e}))})}),i&&(0,G.jsxs)(`fieldset`,{className:`order-cost-presets`,"data-testid":`cost-presets`,children:[(0,G.jsxs)(`legend`,{children:[`常用成本 `,(0,G.jsx)(`span`,{className:`small muted`,children:`按实际发生勾选 · 快递二选一,也可不选`})]}),(0,G.jsxs)(`div`,{className:`order-cost-options`,children:[a.length===0&&(0,G.jsx)(`p`,{className:`muted`,children:`暂无启用的勾选成本,可在店铺配置中添加。`}),a.map(e=>{let a=!!i.checked[e.kind];return(0,G.jsxs)(`div`,{className:`order-cost-option`+(a?` checked`:``),"data-preset":e.kind,children:[(0,G.jsxs)(pn,{className:`order-cost-check`,checked:a,onChange:n=>r(r=>B.togglePreset(r,e.kind,n.target.checked,t,Xe)),children:[(0,G.jsxs)(`span`,{className:`order-cost-main`,children:[(0,G.jsx)(`strong`,{children:e.name}),(0,G.jsx)(`span`,{className:`order-cost-price num`,children:e.price})]}),(0,G.jsx)(`small`,{className:`order-cost-payer`,children:e.kind===`yt`&&!i.configured?n.presetNotes.ytPayer:e.payer})]}),e.byQuantity&&a&&(0,G.jsx)(Ln,{className:`order-cost-quantity`,label:`数量(个)`,field:`cost_`+e.kind+`_quantity`,hint:n.presetNotes[e.kind],children:(0,G.jsx)(ct,{name:`cost_`+e.kind+`_quantity`,"aria-label":e.name+`数量(个)`,inputMode:`numeric`,className:`num`,value:i.quantity[e.kind]??`1`,onChange:t=>r(n=>B.setPresetQuantity(n,e.kind,t.target.value))})})]},e.kind)})]})]}),(0,G.jsx)(`div`,{className:`fee-grid`,children:e.feeRows.map((e,n)=>{let i=e.key.startsWith(`manual:`);return(0,G.jsxs)(`div`,{className:`fee-row`,"data-fee":e.key,"data-fee-index":n,children:[(0,G.jsxs)(`div`,{className:`fee-title`,children:[i?(0,G.jsx)(K,{label:`费用项目名称`,field:`feeNote`,value:e.note,maxLength:150,onChange:e=>r(t=>B.editFeeRow(t,n,`note`,e))}):(0,G.jsx)(`strong`,{className:`fee-name`,children:e.note}),(0,G.jsx)(`span`,{className:`small muted fee-source`,children:B.feeSourceText(e)})]}),(0,G.jsx)(K,{label:`实际成本(元)`,field:`feeAmount`,numeric:!0,value:e.amount,placeholder:`没有成本填0`,onChange:e=>r(t=>B.editFeeRow(t,n,`amount`,e))}),(0,G.jsx)(q,{label:`费用付款人`,field:`feePayer`,value:e.payer,options:B.memberOptions(t,!0,{selected:e.payer}),onChange:e=>r(t=>B.editFeeRow(t,n,`payer`,e))}),(0,G.jsx)(z,{type:`text`,size:`small`,icon:(0,G.jsx)(ce,{}),"data-action":`remove-fee`,onClick:()=>r(e=>B.removeFeeRow(e,n)),children:`移除费用`})]},e.key)})}),n.card&&(0,G.jsxs)(`div`,{className:`credit-card-preview`,"data-testid":`credit-card-preview`,children:[(0,G.jsxs)(`div`,{className:`credit-card-heading`,children:[(0,G.jsx)(`strong`,{children:`信用卡手续费`}),(0,G.jsx)(`span`,{className:`small muted`,children:`自动计算 · 客户单据不显示`})]}),(0,G.jsxs)(W,{gutter:[16,14],children:[(0,G.jsx)(K,{span:zn,label:`手续费(元,自动)`,field:`credit_card_fee`,value:n.card.amountText,readOnly:!0}),(0,G.jsx)(q,{span:zn,label:`手续费付款人`,field:`credit_card_fee_payer`,value:e.credit_card_fee_payer,options:B.memberOptions(t),onChange:e=>r(t=>({...t,credit_card_fee_payer:e}))})]}),(0,G.jsx)(`p`,{className:`small muted`,"aria-live":`polite`,children:n.card.formula})]}),(0,G.jsx)(`div`,{className:`fees-total num`,"data-testid":`fees-total`,children:n.feesText})]})}function $n({form:e,tags:t,tagsStatus:n,busy:r,update:i,onError:a}){let o=B.filterNoteTags(t,e.internal_note),s=/(?:^|[\s,。;、])#([\p{L}\p{N}_-]*)$/u.test(e.internal_note),c=(0,V.useRef)(null);return(0,G.jsxs)(Bn,{id:`section-summary`,step:`04`,title:`优惠与备注`,children:[(0,G.jsxs)(W,{gutter:[16,14],children:[(0,G.jsx)(K,{span:{xs:24,md:8},label:`整单优惠/抹零(元)`,field:`discount`,numeric:!0,value:e.discount,onChange:e=>i(t=>({...t,discount:e}))}),(0,G.jsx)(Ln,{span:{xs:24,md:16},label:`客户单备注`,field:`note`,id:`order-note`,children:(0,G.jsx)(ct.TextArea,{id:`order-note`,name:`note`,"aria-label":`客户单备注`,maxLength:240,autoSize:{minRows:1,maxRows:4},placeholder:`只写可让客户看到的内容`,value:e.note,onChange:e=>i(t=>({...t,note:e.target.value}))})})]}),(0,G.jsxs)(`div`,{className:`internal internal-note`,children:[(0,G.jsx)(Ln,{label:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(it,{"aria-hidden":`true`}),` 内部备注 `,(0,G.jsx)(`span`,{className:`small muted`,children:`必填,至少3个字符(含#号),最多500字`})]}),help:`输入 #词语 添加标签,例如 #补货、#客户自提。保存订单后可复用,点击下方标签即可填入。内部备注不会出现在客户销售单或打印件中。`,field:`internal_note`,id:`order-internal-note`,children:(0,G.jsx)(ct.TextArea,{ref:c,id:`order-internal-note`,name:`internal_note`,"aria-label":`内部备注`,maxLength:500,autoSize:{minRows:2,maxRows:6},placeholder:`仅供内部跟进,不会出现在客户销售单或打印件中`,value:e.internal_note,onChange:e=>i(t=>({...t,internal_note:e.target.value}))})}),(0,G.jsx)(`div`,{className:`order-note-tag-options`,"aria-label":`内部备注快捷标签`,"data-testid":`note-tags`,children:n?(0,G.jsx)(`span`,{className:`small muted`,children:n}):o.length?o.map(t=>{let n=e.internal_note.includes(t);return(0,G.jsx)(z,{size:`small`,className:`note-tag`+(n?` note-tag-active`:``),"data-note-tag":t,"aria-pressed":n,disabled:r,onClick:()=>{try{let n=B.insertNoteTag(e.internal_note,t);i(e=>({...e,internal_note:n})),window.setTimeout(()=>c.current?.focus(),0)}catch(e){a(e.message)}},children:t},t)}):(0,G.jsx)(`span`,{className:`small muted`,children:s?`没有匹配标签,可继续输入新标签。`:`暂无已保存标签,填写 #词语 并保存订单后即可复用。`})})]})]})}function er({form:e,summary:t,busy:n,error:r,onClearError:i,onLocateError:a}){let o=String(e.discount).trim(),s=/^\d+(?:\.\d{1,2})?$/.test(o)?Math.round(Number(o)*100):0;return(0,G.jsxs)(`div`,{className:`submit-bar`,role:`region`,"aria-label":`成交合计与提交`,children:[r&&(0,G.jsx)(M,{type:`error`,showIcon:!0,closable:!!i,onClose:i,message:r,action:a?(0,G.jsx)(z,{size:`small`,type:`link`,danger:!0,onClick:a,children:`定位问题项`}):void 0,className:`order-error`,role:`alert`,"data-testid":`order-error`}),(0,G.jsxs)(`div`,{className:`submit-bar-row`,children:[(0,G.jsxs)(`div`,{className:`submit-total`,children:[(0,G.jsx)(`span`,{className:`submit-label`,children:`成交合计`}),(0,G.jsx)(`div`,{className:`summary-amount num`+(t.total==null?` pending`:``),"data-testid":`create-total`,children:t.totalText})]}),(0,G.jsxs)(`div`,{className:`submit-facts`,children:[(0,G.jsxs)(`span`,{className:`fact`,children:[e.lines.length,` 件商品`,s>0?(0,G.jsxs)(G.Fragment,{children:[` · 整单优惠 −¥`,B.yuan(s)]}):null]}),(0,G.jsx)(`span`,{className:`fact muted`,"aria-live":`polite`,"data-testid":`rounding-note`,children:t.roundingHint})]}),(0,G.jsx)(z,{type:`primary`,htmlType:`submit`,size:`large`,icon:(0,G.jsx)(Ve,{}),loading:n,"data-action":`issue`,className:`issue-button`,children:`生成销售单据`})]})]})}var Q=(e,...t)=>{for(let n of t){let t=e?.querySelector(`[data-field="${n}"]`);if(t&&!t.querySelector(`input[readonly]`))return t}return null},$=(e,t)=>e.querySelector(`[data-line="${Number(t[1])-1}"]`),tr=(e,t,n)=>{for(let r of e?.querySelectorAll(t)||[]){let e=r.querySelector(`[data-field="${n}"]`);if(e&&!e.querySelector(`input`)?.value)return e}return null},nr=[[/客户称呼/,e=>Q(e,`customer`)],[/客户类型/,e=>Q(e,`customer_type`)],[/开单人/,e=>Q(e,`salesperson`)],[/内部备注/,e=>Q(e,`internal_note`)],[/费用实际支付日期/,e=>Q(e,`fees_date`)],[/业务日期/,e=>Q(e,`date`)],[/整单优惠/,e=>Q(e,`discount`)],[/盒子数量|数量请填写正整数/,e=>e.querySelector(`[data-field^="cost_"][data-field$="_quantity"]`)],[/商品 (\d+)的名称/,(e,t)=>Q($(e,t),`customName`,`nameType`)],[/商品 (\d+)的克重/,(e,t)=>Q($(e,t),`quantity`)],[/商品 (\d+)的计工费件数/,(e,t)=>Q($(e,t),`pieces`)],[/商品 (\d+)的金价/,(e,t)=>Q($(e,t),`goldPrice`)],[/商品 (\d+)的销售工费/,(e,t)=>Q($(e,t),`laborRate`)],[/商品 (\d+)的基础金额/,(e,t)=>Q($(e,t),`baseSale`)],[/商品 (\d+)出库数量/,(e,t)=>Q($(e,t),`stockCount`)],[/商品 (\d+)(?:附加项目|的.+收费)/,(e,t)=>tr($(e,t),`[data-charge]`,`chargeAmount`)],[/商品 (\d+)请选择料费付款人|商品 (\d+)请选择料费和/,(e,t)=>Q($(e,t),`cost-materialPayer`)],[/商品 (\d+)请选择进货工费付款人/,(e,t)=>Q($(e,t),`cost-laborPayer`)],[/商品 (\d+)请选择不晚于/,(e,t)=>Q($(e,t),`materialPoolId`)],[/商品 (\d+)的料费成本/,(e,t)=>Q($(e,t),`cost-materialRate`,`cost-material`)],[/商品 (\d+)的进货工费/,(e,t)=>Q($(e,t),`cost-laborRate`,`cost-labor`)],[/商品 (\d+)的(?:配件成本)/,(e,t)=>Q($(e,t),`cost-accessories`)],[/商品 (\d+)的(?:其他货品成本)/,(e,t)=>Q($(e,t),`cost-other`)],[/商品 (\d+)的货品成本/,(e,t)=>Q($(e,t),`cost`)],[/商品 (\d+):/,(e,t)=>$(e,t)],[/的实际成本|实际成本/,e=>tr(e,`.fee-row`,`feeAmount`)||Q(e.querySelector(`.fee-row`),`feeAmount`)]];function rr(e,t){let n=null;for(let[r,i]of nr){let a=r.exec(t);if(!a||n&&a.index>=n.index)continue;a[1]===void 0&&a[2]!==void 0&&(a[1]=a[2]);let o=i(e,a);o&&(n={index:a.index,el:o})}return n?.el||null}function ir(e,t){if(!e||!t)return;let n=rr(e,t);if(!n)return;e.querySelectorAll(`.field-invalid`).forEach(e=>e.classList.remove(`field-invalid`)),n.classList.add(`field-invalid`),n.scrollIntoView?.({block:`center`,behavior:`smooth`});let r=n.querySelector(`input:not([type=hidden]):not([readonly]), textarea`);window.setTimeout(()=>r?.focus({preventScroll:!0}),350);let i=()=>{n.classList.remove(`field-invalid`),n.removeEventListener(`input`,i),n.removeEventListener(`click`,i)};n.addEventListener(`input`,i),n.addEventListener(`click`,i)}function ar({client:e,state:t,session:n,form:r,ctx:i,update:a,reset:o}){return(0,G.jsx)(kt,{className:`entry-tools`,items:[{key:`templates`,label:(0,G.jsxs)(`span`,{children:[`开单模板 `,(0,G.jsx)(`span`,{className:`small muted`,children:`选择或保存常用模板`})]}),children:(0,G.jsx)(or,{client:e,state:t,session:n,form:r,reset:o})},...r.id?[]:[{key:`formula`,label:(0,G.jsxs)(`span`,{children:[`公式快速开单 `,(0,G.jsx)(`span`,{className:`small muted`,children:`粘贴公式,自动填入商品`})]}),children:(0,G.jsx)(sr,{form:r,ctx:i,update:a})}]]})}function or({client:e,state:t,session:n,form:r,reset:i}){let{message:a,modal:o}=h.useApp(),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)({text:``}),[p,m]=(0,V.useState)(null),g=r.member||B.currentMember(t),_=B.teamMode(t),v=(0,V.useCallback)(async()=>{try{let n=_&&t.user.role===`owner`?`?`+new URLSearchParams({member:g}):``,r=await e.api(`/api/order-templates`+n);if(!Array.isArray(r.rows))throw Error(`模板列表未完整返回,请重试。`);return c(r.rows),u(e=>r.rows.some(t=>t.id===e)?e:``),!0}catch(e){return f({text:`模板尚未读到:`+e.message,error:!0}),!1}},[e,g,_,t.user.role]);(0,V.useEffect)(()=>{v()},[v]);let y=B.defaultSalesperson(t,n);async function b(n){if(e.busy)throw Error(`正在处理订单,请稍候再套用模板。`);if(e.pending())throw Error(`请先恢复上次未确认的操作,再套用模板。`);let s=t.user.id,[c,d]=await Promise.all([e.api(`/api/order-templates/`+encodeURIComponent(n)),e.api(`/api/session`)]);if(d.user?.id!==s)throw Error(`登录账号已变化,请刷新后再套用模板。`);let p=Ye.apply(c.preset,{today:d.today,salesperson:y,pocketKeys:[...new Set([...B.activePocketKeys(t),...(c.preset.lines||[]).map(e=>e.pocket||``).filter(Boolean)])]});p.salesperson=y,_&&(p.member=c.member||g);let m=B.collectDraft(r,t);(!Je.hasDraftContent(m,{today:d.today,salesperson:y})&&!l&&!m.lines.some(e=>e.pricingMode===`manual`||e.laborMode&&e.laborMode!==`gram`||e.pieces!=null&&String(e.pieces)!==`1`||e.costLabor?.mode===`gram`||e.costMaterial?.mode===`total`)||await o.confirm({title:`套用模板`,content:`当前还有未保存的开单内容。套用模板会替换这份草稿,客户称呼将留空、日期改为今天,是否继续?`,okText:`继续`,cancelText:`取消`}))&&(i(p),u(n),f({text:`已套用「`+c.name+`」,请核对本次克重、报价和费用后生成单据。`}),a.success(`模板已填入,生成销售单据后才记账`))}async function x(){if(!p)return;let n=p.name.trim();try{if(!n||n.length>60)throw Error(`模板名称请填写1~60字。`);let i=p.kind===`update`?s?.find(e=>e.id===l):null,o={..._?{member:g}:{},name:n,preset:Ye.fromDraft(B.collectDraft(r,t),{pocketKeys:B.activePocketKeys(t),newId:Xe}),...i?{revision:i.revision}:{}},c=`/api/order-templates`+(i?`/`+encodeURIComponent(i.id)+`/update`:``),d=await e.mutate(c,o);m(null),u(d.id);let h=await v();f({text:`已保存模板「`+(d.name||n)+`」`+(h?`。`:`;列表暂未读到,可重新读取,当前表单已保留。`)}),a.success(`模板已保存,当前开单内容保留`)}catch(e){m(t=>t&&{...t,error:e.message.replace(`不要重新开单`,`不要重复保存模板`)})}}async function S(){let t=s?.find(e=>e.id===l);if(t&&await o.confirm({title:`删除模板`,content:`删除模板「`+t.name+`」?当前开单内容和已保存订单会保留。`,okText:`删除`,cancelText:`取消`}))try{await e.mutate(`/api/order-templates/`+encodeURIComponent(t.id)+`/delete`,{revision:t.revision}),u(``),await v(),f({text:`模板已删除。`})}catch(e){f({text:e.message,error:!0})}}return(0,G.jsxs)(`div`,{className:`template-panel`,children:[(0,G.jsxs)(lt,{wrap:!0,children:[(0,G.jsx)(at,{"aria-label":`选择模板`,"data-testid":`template-select`,style:{minWidth:220},allowClear:!0,value:l||void 0,placeholder:s?`选择后自动填入预设`:`正在读取模板…`,disabled:!s,options:(s||[]).map(e=>({value:e.id,label:e.name})),onChange:e=>{e?b(e).catch(e=>f({text:e.message,error:!0})):u(``)}}),(0,G.jsx)(z,{onClick:()=>m({kind:`new`,name:``,error:``}),children:`保存为新模板`}),(0,G.jsx)(z,{disabled:!l,onClick:()=>m({kind:`update`,name:s?.find(e=>e.id===l)?.name||``,error:``}),children:`更新所选模板`}),(0,G.jsx)(z,{disabled:!l,onClick:()=>void S(),children:`删除模板`})]}),(0,G.jsx)(`p`,{className:`small muted`,children:`用于普通开单,可以保存未填完的表单。客户称呼和内部备注不存入模板,套用时留空;业务日期和费用日期用今天;每日料价随本次订单日期读取。`}),d.text&&(0,G.jsx)(`p`,{className:`small `+(d.error?`danger-text`:`muted`),children:d.text}),(0,G.jsxs)(U,{open:!!p,title:p?.kind===`update`?`更新模板`:`保存为新模板`,okText:p?.kind===`update`?`保存更新`:`保存模板`,cancelText:`取消`,onOk:()=>void x(),onCancel:()=>m(null),confirmLoading:e.busy,children:[(0,G.jsx)(`p`,{className:`small muted`,children:`将当前普通开单表单保存为预设,允许金额和克重留空。客户、内部备注、日期及订单编号不存入模板;本次正在填写的内容会保留。`}),(0,G.jsx)(ct,{"aria-label":`模板名称`,maxLength:60,autoFocus:!0,placeholder:`例如:足金手链常用报价`,value:p?.name||``,onChange:e=>m(t=>t&&{...t,name:e.target.value}),onPressEnter:()=>void x()}),p?.error&&(0,G.jsx)(M,{type:`error`,showIcon:!0,message:p.error,style:{marginTop:12}})]})]})}function sr({form:e,ctx:t,update:n}){let[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(null);function s(s){try{let c=qe.parseBatch(r,{roundingMode:e.rounding_mode}),l=c.items.map((e,t)=>{let n=e.line,r=n.laborMode===`gram`?`${n.quantity}克 ×(金价 ${n.goldPrice} + 克工费 ${n.laborRate})`:`${n.quantity}克 × 金价 ${n.goldPrice} + 1件 × 件工费 ${n.laborRate}`;return`本次第 ${t+1} 件:${r}${n.charges.map(e=>` + 附加费 `+e.amount).join(``)} = ${B.yuan(e.subtotal)}元`});if(l.push(`本次商品合计 ${B.yuan(c.subtotal)}元${c.roundingMode===`yuan`?`,整单取整为 `+B.yuan(c.total)+`元`:``}。`),c.mismatch&&!s){o({kind:`warning`,title:`公式金额与计算结果不一致`,lines:[...l,...c.warnings,`请修改公式,或按计算结果预填。`],pending:r});return}if(s&&a?.pending!==r)throw Error(`公式已改变,请重新点击“识别并预填”核对`);let u=B.applyFormulaLines(e,c.lines,t),d=u.filled;n(()=>u.form),o({kind:`note`,title:`已预填商品 ${d.join(`、`)},共 ${d.length} 件`,lines:[...l,...c.mismatch?[`已采用左侧公式计算金额,未采用不一致的手写金额。`]:[],(c.lines.some(e=>e.charges.length)?`附加费已填金额,未判断编绳、烤漆等类目,可自行改名;内部成本请另行核对。`:``)+`已有商品、优惠和客户资料保留,尚未生成订单。`]}),i(``)}catch(e){o({kind:`error`,lines:[e.message]})}}return(0,G.jsxs)(`div`,{className:`formula-panel`,children:[(0,G.jsx)(ct.TextArea,{"aria-label":`粘贴销售公式`,rows:4,maxLength:18e3,autoComplete:`off`,placeholder:`0.79×822+120=769 0.58×(822+45)+55=558 769+558=1327`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&r.trim()&&(e.preventDefault(),s(!1))}}),(0,G.jsxs)(lt,{wrap:!0,style:{marginTop:8},children:[(0,G.jsx)(z,{type:`primary`,onClick:()=>s(!1),children:`识别并预填`}),a?.kind===`warning`&&(0,G.jsx)(z,{onClick:()=>s(!0),children:`按计算金额预填`}),r&&(0,G.jsx)(z,{onClick:()=>{i(``),o(null)},children:`清空公式`})]}),(0,G.jsx)(`p`,{className:`small muted`,children:`括号内是克工费;金价乘克重后加的是一件工费,再加的金额记为附加费。合计行只校验,不增加商品。客户、货盘及内部成本仍按实际填写。`}),a&&(0,G.jsx)(M,{role:`status`,type:a.kind===`note`?`success`:a.kind,message:a.title||(a.kind===`error`?a.lines[0]:``),description:a.kind===`error`?void 0:(0,G.jsx)(`div`,{children:a.lines.filter(Boolean).map((e,t)=>(0,G.jsx)(`p`,{children:e},t))})})]})}function cr({order:e,error:t,onRetry:n,onPreview:r,onNew:i}){let{message:a}=h.useApp(),[o,s]=(0,V.useState)(!1),c=e.total!==void 0;async function l(){if(e.paper_number)try{await navigator.clipboard.writeText(e.paper_number),s(!0),a.success(`已复制纸单号 `+e.paper_number),window.setTimeout(()=>s(!1),1800)}catch{s(!1),a.info(`请手动选择纸单号复制`)}}return(0,G.jsx)(`div`,{className:`issued-page`,children:(0,G.jsx)(ot,{className:`issued-card`,children:(0,G.jsx)(ee,{status:`success`,title:`销售单据已生成`,subTitle:c?e.materialCostPending?`收款、费用和出库已记账;料费待补,补足购料后自动核算利润。`:`收款、费用、出库和利润已记账。`:t||`正在读取已生成的销售单…`,extra:(0,G.jsxs)(lt,{direction:`vertical`,size:`large`,style:{width:`100%`},children:[c&&(0,G.jsxs)(`dl`,{className:`issued-summary`,"data-testid":`issued-summary`,children:[(0,G.jsxs)(`div`,{className:`issued-item`,children:[(0,G.jsx)(`dt`,{children:(0,G.jsx)(Ge.Text,{type:`secondary`,children:`纸单号`})}),(0,G.jsxs)(`dd`,{className:`issued-value-row`,children:[(0,G.jsx)(`span`,{className:`issued-value num`,"data-testid":`issued-paper-number`,children:e.paper_number||`未分配`}),e.paper_number&&(0,G.jsx)(Ke,{title:o?`已复制`:`复制纸单号`,children:(0,G.jsx)(z,{type:`text`,size:`small`,className:`issued-copy-btn`,"aria-label":`复制纸单号`,icon:o?(0,G.jsx)(Ve,{}):(0,G.jsx)(Ue,{}),onClick:()=>void l()})})]})]}),(0,G.jsxs)(`div`,{className:`issued-item`,children:[(0,G.jsx)(`dt`,{children:(0,G.jsx)(Ge.Text,{type:`secondary`,children:`成交合计`})}),(0,G.jsx)(`dd`,{className:`issued-value issued-total num`,"data-testid":`issued-total`,children:C(e.total??null,e.rounding_mode||`cent`)})]}),e.customer&&(0,G.jsxs)(`div`,{className:`issued-item`,children:[(0,G.jsx)(`dt`,{children:(0,G.jsx)(Ge.Text,{type:`secondary`,children:`客户`})}),(0,G.jsx)(`dd`,{className:`issued-value small`,children:e.customer})]})]}),(0,G.jsxs)(`div`,{className:`issued-actions`,children:[(0,G.jsx)(z,{type:`primary`,size:`large`,icon:(0,G.jsx)(Pn,{}),href:`/print/`+encodeURIComponent(e.id)+`?mode=full`,onClick:()=>{r().catch(e=>a.error(e.message))},target:`_blank`,rel:`noopener`,"data-action":`print-preview`,children:`打开打印预览`}),(0,G.jsx)(z,{size:`large`,icon:(0,G.jsx)(st,{}),onClick:i,"data-action":`new-order`,children:`开始新的一单`}),!c&&(0,G.jsx)(z,{size:`large`,onClick:n,children:`重新读取订单`})]}),(0,G.jsx)(z,{href:b(`orders`)+`?order=`+encodeURIComponent(e.id),onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),k(`orders`,{search:`?order=`+encodeURIComponent(e.id)}))},type:`link`,icon:(0,G.jsx)(gn,{}),children:`查看订单详情`})]})})})})}function lr(e){let{client:t,state:n}=e,r=E(`draft`),[i,a]=(0,V.useState)(r?null:{draft:_(window.localStorage,n.user.id),note:``});return(0,V.useEffect)(()=>{if(!r)return;let e=!0;return(async()=>{try{if(n.user.role!==`owner`)throw Error(`已有草稿由店主继续填写并开单;无单号的新开单流程照常使用。`);let i=await t.api(`/api/orders/`+encodeURIComponent(r));if(i.status!==`draft`)throw Error(`这张订单不是未开单的旧草稿,请在订单页查看。`);e&&a({draft:B.draftInputs(i),note:`正在继续填写旧草稿,生成销售单据后完成记账。`})}catch(t){e&&a({draft:_(window.localStorage,n.user.id),note:`旧草稿未能打开:`+t.message})}})(),()=>{e=!1}},[t,r,n.user.id,n.user.role]),i?(0,G.jsx)(ur,{...e,initialDraft:i.draft,initialNote:i.note}):(0,G.jsx)(`div`,{className:`page-loading`,children:(0,G.jsx)(y,{tip:`正在读取旧草稿…`,children:(0,G.jsx)(`div`,{style:{height:60}})})})}function ur({client:e,state:t,session:n,refreshState:r,onAccountChanged:i,onRecoverOther:a,initialDraft:o,initialNote:s}){let{message:c}=h.useApp();O(e);let{store:l,update:u,reset:d,ctx:f,poolError:p,loadPools:m}=Ze({client:e,state:t,session:n,initialDraft:o}),{form:g,summary:_}=l,[v,y]=(0,V.useState)(``),[C,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(null),D=T!==null,j=(0,V.useRef)(!1);(0,V.useEffect)(()=>{!D&&!j.current&&A(window.localStorage,t.user.id,l.draft)},[D,t.user.id,l.draft]);let[ee,te]=(0,V.useState)([]),[ne,re]=(0,V.useState)(`正在读取快捷标签…`),N=e.busy,ie=e.pending(),P=(0,V.useRef)(null),[ae,oe]=(0,V.useState)(null),se=(0,V.useMemo)(()=>{if(g.paper_number){let e=g.paper_date&&g.paper_number.match(/^\d{8}-?(\d+)$/);return e?g.date.replaceAll(`-`,``)+e[1]:g.paper_number}return ae?.date===g.date?ae.number+`(预计)`:`保存时分配`},[g.paper_number,g.paper_date,g.date,ae]);(0,V.useEffect)(()=>{if(g.paper_number)return;let t=!0,n=g.date;return e.api(`/api/paper-number?date=`+encodeURIComponent(n)).then(e=>t&&oe({date:n,number:e.number})).catch(()=>{}),()=>{t=!1}},[e,g.date,g.paper_number]),(0,V.useEffect)(()=>{let t=!0;return e.api(`/api/order-note-tags`).then(e=>{t&&(te(Array.isArray(e.tags)?e.tags.filter(e=>typeof e==`string`):[]),re(``))}).catch(()=>t&&re(`快捷标签暂未读取成功,可直接填写备注。`)),()=>{t=!1}},[e]);let ce=(0,V.useCallback)(e=>{let t=e;t.code===`ACCOUNT_CHANGED`&&w(!0),y(t.message),c.error(t.message),ir(P.current,t.message)},[c]),le=(0,V.useCallback)(async(t,n)=>{E({order:{id:n.id},error:``});try{let t=await e.api(`/api/orders/`+encodeURIComponent(n.id));E({order:{...t,id:n.id},error:``}),c.success(t.materialCostPending?`销售单据已生成;料费待补,补足购料后自动核算利润`:`销售单据已生成,收款、费用、出库和利润已记账`),r().catch(()=>{})}catch{E({order:{id:n.id,customer:t},error:`销售单据已经生成,最新订单暂未读到。请重新读取或查看已生成销售单;不要重复开单。`})}},[e,c,r]);async function ue(){y(``);try{B.validateFormFields(g,t);let n=B.validateIssueDraft(B.collectDraft(g,t),t);if(n.id&&t.user.role!==`owner`)throw Error(`已有草稿由店主继续填写并开单;无单号的新开单流程照常使用。`);j.current=!0;let r=await e.mutate(`/api/orders/issue`,n);x(window.localStorage,t.user.id,n),await le(n.customer,r)}catch(e){j.current=!1,ce(e)}}async function de(n){if(n.url!==`/api/orders/issue`&&a)return a();y(``);try{j.current=!0;let r=await e.retryPending();if(r?.result.id&&n.url===`/api/orders/issue`)return x(window.localStorage,t.user.id,r.job.data),await le(r.job.data.customer,{id:r.result.id});j.current=!1,r&&c.success(`原操作已确认,不会重复记账`)}catch(e){j.current=!1,ce(e)}}function fe(){S(window.localStorage,t.user.id),window.location.search&&window.history.replaceState(null,``,window.location.pathname),j.current=!1,E(null),y(``),d(null)}let pe=(0,V.useMemo)(()=>!!(g.id||g.customer.trim()||g.customer_type||g.note.trim()||g.internal_note.trim()||g.discount.trim()&&g.discount.trim()!==`0`||g.lines.length>1||g.lines.some(e=>e.quantity.trim()||e.goldPrice.trim()||e.laborRate.trim()||e.baseSale.trim()||e.charges.length>0)||g.feeRows.length>0||Object.values(g.presets?.checked||{}).some(Boolean)),[g]),F=(0,V.useMemo)(()=>Object.values(g.presets?.checked||{}).filter(Boolean).length+g.feeRows.length,[g.presets,g.feeRows.length]),me=(0,V.useCallback)(e=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})},[]);return T?(0,G.jsx)(cr,{order:T.order,onPreview:()=>e.mutate(`/api/orders/`+encodeURIComponent(T.order.id)+`/print`,{mode:`full`}),error:T.error,onRetry:()=>void le(T.order.customer,{id:T.order.id}),onNew:fe}):(0,G.jsxs)(`div`,{className:`create-page`,children:[(0,G.jsxs)(`div`,{className:`page-heading`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`New Order · 新版界面`}),(0,G.jsx)(Ge.Title,{level:1,children:`开一张新单`}),(0,G.jsx)(Ge.Paragraph,{type:`secondary`,children:`开单即交付,一次记录全额收款、实际费用、出库和利润。`})]}),(0,G.jsxs)(`div`,{className:`order-heading-actions`,children:[(0,G.jsx)(z,{href:b(`price-lock-create`),disabled:N,onClick:e=>{e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),k(`price-lock-create`))},children:`锁价`}),pe?(0,G.jsx)(En,{title:`确定清空当前表单?`,description:`已填写的商品、费用与备注都会清除,且无法撤销。`,okText:`确认清空`,cancelText:`保留`,okButtonProps:{danger:!0},onConfirm:()=>{fe(),c.success(`表单已清空`)},children:(0,G.jsx)(z,{icon:(0,G.jsx)(An,{}),"data-action":`clear-draft`,disabled:N,children:`清空表单`})}):(0,G.jsx)(z,{icon:(0,G.jsx)(An,{}),"data-action":`clear-draft`,disabled:N,onClick:()=>{fe(),c.info(`当前表单已是空白`)},children:`清空表单`})]})]}),ie&&(0,G.jsx)(M,{className:`pending`,type:`warning`,showIcon:!0,"data-testid":`pending`,message:`上次提交结果尚未确认,请先恢复原操作。重试会使用同一个操作号。`,action:(0,G.jsx)(z,{danger:!0,size:`small`,disabled:N,"data-action":`retry`,onClick:()=>void de(ie),children:`恢复原操作`})}),C&&(0,G.jsx)(M,{type:`error`,showIcon:!0,message:`登录账号已在其他页面切换,原操作已暂停。`,action:(0,G.jsx)(z,{size:`small`,onClick:i,children:`重新读取登录状态`})}),s&&(0,G.jsx)(M,{type:`info`,showIcon:!0,message:s}),g.copy_kind&&(0,G.jsx)(M,{type:`info`,showIcon:!0,message:`已复制为未保存的新订单,客户称呼已留空。`}),p&&(0,G.jsx)(M,{type:`warning`,showIcon:!0,message:p}),(0,G.jsx)(ar,{client:e,state:t,session:n,form:g,ctx:f,update:u,reset:e=>d(e)}),(0,G.jsxs)(`nav`,{className:`section-nav`,"aria-label":`表单分区快捷跳转`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`section-pill`,onClick:()=>me(`section-customer`),children:[(0,G.jsx)(`span`,{className:`section-pill-no`,children:`01`}),` 客户与单据`]}),(0,G.jsxs)(`button`,{type:`button`,className:`section-pill`,onClick:()=>me(`section-lines`),children:[(0,G.jsx)(`span`,{className:`section-pill-no`,children:`02`}),` 商品明细`,(0,G.jsx)(`span`,{className:`section-pill-badge`,children:g.lines.length})]}),(0,G.jsxs)(`button`,{type:`button`,className:`section-pill section-pill-internal`,onClick:()=>me(`section-fees`),children:[(0,G.jsx)(`span`,{className:`section-pill-no`,children:`03`}),` 实际费用`,F>0?(0,G.jsx)(`span`,{className:`section-pill-badge`,children:F}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:`section-pill`,onClick:()=>me(`section-summary`),children:[(0,G.jsx)(`span`,{className:`section-pill-no`,children:`04`}),` 优惠与备注`]})]}),(0,G.jsx)(`form`,{id:`order-form`,ref:P,className:`order-form`,noValidate:!0,onSubmit:e=>{e.preventDefault(),N||ue()},children:(0,G.jsxs)(`fieldset`,{disabled:N,className:`form-fieldset`,children:[(0,G.jsx)(Vn,{form:g,state:t,paperNumber:se,update:u}),(0,G.jsx)(Xn,{client:e,form:g,state:t,update:u,onError:e=>c.error(e),onReloadPools:()=>void m()}),(0,G.jsx)(Qn,{form:g,state:t,summary:_,update:u}),(0,G.jsx)($n,{form:g,tags:ee,tagsStatus:ne,busy:N,update:u,onError:e=>c.error(e)}),(0,G.jsx)(er,{form:g,summary:_,busy:N,error:v,onClearError:()=>y(``),onLocateError:()=>ir(P.current,v)})]})})]})}export{lr as CreateOrderPage};