1import{o as Si}from"./rolldown-runtime-ifEikEFx.js";import{Q as hs,at as gs,it as nn,n as Yn,rt as Ti,t as Ei}from"./react-vendor-CM1iR3-9.js";import{B as Pt,Bt as Re,Ct as fs,Dt as w,Et as xs,G as kt,Gt as ks,It as De,Kt as Ii,On as bs,P as X,Pt as ne,Q as zt,R as J,Rt as fe,St as Me,Vt as js,Z as Un,_t as Vn,at as It,bt as rn,dt as Ht,ft as qn,gn as vs,gt as Ee,it as Le,lt as m,mt as Ss,nt as Ts,pt as Ci,q as _e,qt as ce,st as W,ut as Dn,vt as Es,xt as wi,yt as F,z as V,zt as st}from"./antd-vendor-D7gwNWgM.js";import{i as Zn,m as Is,n as Cs,p as ws,r as Pi}from"./query-vendor-Cvd8942y.js";import{t as Ps}from"./errorHandler-CFfbz1t3.js";import{n as Qe}from"./AuthContext-DfUhvON3.js";import{n as Ze}from"./apiClient-CILLJVNS.js";import{n as zs}from"./queryHelpers-DO4xxDcy.js";import{a as jn,i as xr,n as vn}from"./useApiQuery-B7HY4T8t.js";import{n as As,t as kr}from"./usePermissions-CL4A21Xo.js";import{C as Ls,Dt as zi,Er as Rs,Fn as Ms,Jt as mt,Nr as Bs,Rn as Ds,T as _s,Vn as Ct,Vr as $s,Wn as yt,Zn as Os,an as Ai,et as ut,gr as Fs,it as an,jr as _n,kr as $n,lr as Ns,m as Ks,nn as Hs,pt as Ws,rt as Gs,vr as Li}from"./icons-vendor-CSnqyHkR.js";import{t as _}from"./HIcon-hlKShEDM.js";import{t as Ie}from"./apiChannels-4YZw6XOH.js";import{t as Ys}from"./use-reduced-motion-DKfodfp-.js";import{r as Qn}from"./dayjs-BTc2jIjn.js";import{D as Ve,E as Ri,I as gt,Lt as Mi,Pt as Us,T as Xe,a as it,c as Vs,h as Bi,m as qs,s as Di,ut as _i}from"./index-DOYYfOv6.js";import{$ as $i,$t as Zs,Cn as Qs,Ln as Xs,Mn as $t,Rn as Js,Rt as el,Tn as tl,X as nl,Y as rl,Zt as il,_ as Oi,bt as br,d as Fi,f as On,on as Ni,sn as al,t as Ki,tt as sl,u as Hi,v as ll,w as ol,wn as jr,x as cl,y as dl}from"./LineChart-DAeqN2te.js";import{t as ul}from"./deepEqual-B9Df-Ffk.js";import{t as ml}from"./useChartTheme-Coy5GtdP.js";import{a as Be,n as Sn,r as he,t as yl}from"./currency-D8iO71v8.js";import{t as sn}from"./typeGuards-BbULCrkz.js";import{t as pl}from"./product-tags-B23bERnS.js";import{i as Yt,n as Wi,r as Ut,t as Vt}from"./marketplacePriceFields-sx9ZqejI.js";import{t as vr}from"./dateFormat-CNItYbSP.js";import{a as hl,s as gl}from"./usePricing-oJBgNFlQ.js";import{A as fl,C as Sr,D as ze,E as Tr,F as xl,I as Er,L as Xn,M as kl,N as Wt,O as at,P as qt,R as bl,S as jl,T as Gi,_ as vl,b as Ir,g as Cr,h as wr,j as Jn,k as Sl,l as Tl,n as El,o as Il,r as Yi,s as Cl,t as Ui,u as wl,v as Pl,w as zl,x as Al,y as Ll}from"./trNumberInput-DcCSpQfU.js";import{n as Rl,t as Ml}from"./ReferenceLine-DdgcYZSE.js";import{c as Pr,d as Ae,l as Bl,n as Zt,s as Dl,t as _l}from"./PublishWizard-CbgiEZWh.js";import{i as $l,n as zr,r as Ol,t as Fl}from"./productDetails-B8pDTh-b.js";import{n as Ar}from"./useUrlDrawer-KgaoWkg7.js";import{t as Nl}from"./productDetailsSelect-DzkbRJ_6.js";import{t as Qt}from"./MarketplaceMark-CvflBj9e.js";import{t as Lr}from"./formatDesi-ClOL8J1I.js";import{A as Kl,C as Hl,D as Wl,E as Vi,N as Gl,O as qi,T as Yl,a as Pe,c as Ul,d as Rr,g as Vl,i as Ot,j as ql,k as Zl,o as Ft,r as Mr,u as Ql,w as Xl,x as Jl,y as eo}from"./profitFormat-B-iMCohD.js";import{t as to}from"./MergeHistoryPanel-CLE_mIeF.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"[email protected]+202610012304"};var n=new t.Error().stack;
1n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="a38de996-1d60-4715-8c47-c933a1524b9d",t._sentryDebugIdIdentifier="sentry-dbid-a38de996-1d60-4715-8c47-c933a1524b9d")}catch{}})();var y=Si(bs());function Br(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);n&&(i=i.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,i)}return r}function Dr(t){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?Br(Object(r),!0).forEach(function(i){no(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Br(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}function no(t,n,r){return(n=ro(n))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function ro(t){var n=io(t,"string");return typeof n=="symbol"?n:n+""}function io(t,n){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function Xt(){return Xt=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)({}).hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Xt.apply(null,arguments)}var ao=(t,n,r,i,a,s,l)=>{var d,g,o,p,c=l.x1,u=l.x2,h=l.y1,x=l.y2;if(a==null||s==null)return null;var b=new Rl({x:a,y:s}),E={x:t?(d=a.map(c,{position:"start"}))!==null&&d!==void 0?d:null:a.rangeMin(),y:r?(g=s.map(h,{position:"start"}))!==null&&g!==void 0?g:null:s.rangeMin()},S={x:n?(o=a.map(u,{position:"end"}))!==null&&o!==void 0?o:null:a.rangeMax(),y:i?(p=s.map(x,{position:"end"}))!==null&&p!==void 0?p:null:s.rangeMax()};return l.ifOverflow==="discard"&&(!b.isInRange(E)||!b.isInRange(S))?null:ol(E,S)},so=(t,n)=>{var r;return y.isValidElement(t)?r=y.cloneElement(t,n):typeof t=="function"?r=t(n):r=y.createElement(il,Xt({},n,{className:"recharts-reference-area-rect"})),r};function lo(t){var n=Qs();return(0,y.useEffect)(()=>(n(dl(t)),()=>{n(cl(t))})),null}function oo(t){var n=t.x1,r=t.x2,i=t.y1,a=t.y2,s=t.className,l=t.shape,d=t.xAxisId,g=t.yAxisId,o=ll(),p=al(),c=jr(j=>br(j,"xAxis",d,p)),u=jr(j=>br(j,"yAxis",g,p));if(c==null||u==null)return null;var h=$t(n),x=$t(r),b=$t(i),E=$t(a);if(!h&&!x&&!b&&!E&&!l)return null;var S=ao(h,x,b,E,c,u,t);if(!S&&!l)return null;var M=t.ifOverflow==="hidden"?"url(#".concat(o,")"):void 0;return y.createElement(sl,{zIndex:t.zIndex},y.createElement(Xs,{className:vs("recharts-reference-area",s)},so(l,Dr(Dr({clipPath:M},Js(t)),S)),S!=null&&y.createElement(rl,Xt({},S,{lowerWidth:S.width,upperWidth:S.width}),y.createElement(nl,{label:t.label}),t.children)))}var co={ifOverflow:"discard",xAxisId:0,yAxisId:0,radius:0,fill:"#ccc",label:!1,fillOpacity:.5,stroke:"none",strokeWidth:1,zIndex:el.area};function Zi(t){var n=tl(t,co);return y.createElement(y.Fragment,null,y.createElement(lo,{yAxisId:n.yAxisId,xAxisId:n.xAxisId,ifOverflow:n.ifOverflow,x1:n.x1,x2:n.x2,y1:n.y1,y2:n.y2}),y.createElement(oo,n))}Zi.displayName="ReferenceArea";function uo(t){const n=(0,y.useRef)(!1),r=Zt(t);return(0,y.useCallback)(async(...i)=>{if(!n.current){n.current=!0;try{return await r.current(...i)}finally{n.current=!1}}},[r])}function mo(t){const n=(t??"").trim();return n?/invalid[_ ]grant|invalid refresh token|refresh token/i.test(n)?"MaÄaza yetkilendirmesi (OAuth) sona ermiÅ veya iptal edilmiÅ.":/invalid[_ ]token|token expired|token süresi/i.test(n)?"EriÅim anahtarının süresi dolmuÅ.":/\b401\b|\b403\b|unauthorized|authentication failed/i.test(n)?"Pazaryeri kimlik bilgilerini reddetti.":n.length>200?`${n.slice(0,199)}â¦`:n:null}var Tn=t=>{if(!t)return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:n.toLocaleString("tr-TR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})};function yo(t){const{marketplace:n,marketplaceLabel:r,authStatus:i,lastVerifiedAt:a,canReauthorize:s}=t;if(i?.state!=="failed")return null;const l=Tn(a)??Tn(i.lastOkAt),d=Tn(i.lastErrorAt),g=mo(i.lastErrorMessage),o=[l?`Ekranda görünen durum ${l} tarihinde ${r}'tan alındı; o tarihten bu yana doÄrulanamadı.`:`Bu ilanın ${r} tarafındaki güncel durumu doÄrulanamadı.`,d?`BaÄlantı ${d} tarihinde koptu.`:null,g].filter(p=>!!p);return{severity:"error",title:`${r} baÄlantısı kesildi â aÅaÄıdaki bilgiler doÄrulanamıyor`,detailLines:o,actionLine:s?`Ayarlar â Pazaryerleri â ${r} bölümünden baÄlantıyı yeniden yetkilendirin. Yetkilendirmeden sonra bu karttaki â³ ile durumu tekrar çekin.`:"BaÄlantıyı yenilemek için hesap yöneticinize baÅvurun.",settingsPath:s?`/settings/marketplace/${n}`:null}}var bt=t=>t.barcode??t.merchantSku??t.stockCode??null,po=(t,n)=>Yt(t,n)!==void 0||Ut(t,n)!==void 0;function ho(t,n){const r=[],i=[],a={...n};for(const s of Wi){const l=n[s];if(!Array.isArray(l))continue;const d=t[s]??[],g=Vt[s],o=Xi(l,d);a[s]=l.map((p,c)=>{const u=o(c),h=u?.row;if(!h)return po(p,s)&&i.push({marketplace:s,listingIndex:c,identifier:bt(p),reason:"no-server-row"}),p;const x=Yt(p,s),b=Yt(h,s),E=Ut(p,s),S=Ut(h,s);if(!(x!==void 0&&x!==b)&&!(E!==void 0&&E!==S))return p;const M=x??b;return M===void 0||!(M>0)?(i.push({marketplace:s,listingIndex:u.index,identifier:bt(p)??bt(h),reason:"no-sale-price"}),Fn(p,h,g)):(r.push({marketplace:s,listingIndex:u.index,identifier:bt(p)??bt(h),currentSalePrice:b,salePrice:M,...E!==void 0?{listPrice:E}:{}}),Fn(p,h,g))})}return{edits:r,sanitized:a,skipped:i}}function Fn(t,n,r){const i={...t};return i[r.sale]=n[r.sale],r.list&&(i[r.list]=n[r.list]),i}function Qi(t,n){const r={...n};for(const i of Wi){const a=n[i];if(!Array.isArray(a))continue;const s=t[i]??[],l=Vt[i],d=Xi(a,s);r[i]=a.map((g,o)=>{const p=d(o)?.row;return p?Fn(g,p,l):g})}return r}function Xi(t,n){const r=a=>{const s=n[a];return s?{row:s,index:a}:void 0};if(!t.some(a=>a?.id!=null)||!n.some(a=>a?.id!=null))return r;const i=new Map;
1return n.forEach((a,s)=>{a?.id!=null&&i.set(String(a.id),{row:a,index:s})}),a=>{const s=t[a]?.id;return s==null?void 0:i.get(String(s))}}async function go(t){const{edits:n,body:r,push:i,readServerProduct:a}=t,s=[];for(const d of n)try{await i(d)}catch{s.push(d.marketplace)}const l=await a();return{body:Qi(l,r),failures:s,pushed:s.length<n.length}}var fo=new Set(["INPUT","TEXTAREA","SELECT"]);function xo(t){return!t||!(t instanceof HTMLElement)?!1:!!(t.isContentEditable||fo.has(t.tagName))}function Tt(){return typeof document>"u"?!1:document.querySelector('.ant-modal-wrap:not([style*="display: none"]), .ant-drawer-open, .ant-dropdown:not(.ant-dropdown-hidden), .ant-select-dropdown:not(.ant-select-dropdown-hidden), .ant-popover:not(.ant-popover-hidden)')!==null}function Ji(t){const n=Zt(t);(0,y.useEffect)(()=>{function r(i){const a=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.userAgent)?i.metaKey:i.ctrlKey;for(const s of n.current)i.key.toLowerCase()===s.key.toLowerCase()&&!!s.meta===a&&!!s.shift===i.shiftKey&&(!s.allowInForm&&xo(i.target)||(i.preventDefault(),s.handler(i)))}return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n])}function ko(t){return t.replace(/[&<>"']/g,n=>{switch(n){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";default:return n}})}function bo(t){return Math.min(Math.max(Number(t)||1,1),200)}var jo=["11011001100","11001101100","11001100110","10010011000","10010001100","10001001100","10011001000","10011000100","10001100100","11001001000","11001000100","11000100100","10110011100","10011011100","10011001110","10111001100","10011101100","10011100110","11001110010","11001011100","11001001110","11011100100","11001110100","11101101110","11101001100","11100101100","11100100110","11101100100","11100110100","11100110010","11011011000","11011000110","11000110110","10100011000","10001011000","10001000110","10110001000","10001101000","10001100010","11010001000","11000101000","11000100010","10110111000","10110001110","10001101110","10111011000","10111000110","10001110110","11101110110","11010001110","11000101110","11011101000","11011100010","11011101110","11101011000","11101000110","11100010110","11101101000","11101100010","11100011010","11101111010","11001000010","11110001010","10100110000","10100001100","10010110000","10010000110","10000101100","10000100110","10110010000","10110000100","10011010000","10011000010","10000110100","10000110010","11000010010","11001010000","11110111010","11000010100","10001111010","10100111100","10010111100","10010011110","10111100100","10011110100","10011110010","11110100100","11110010100","11110010010","11011011110","11011110110","11110110110","10101111000","10100011110","10001011110","10111101000","10111100010","11110101000","11110100010","10111011110","10111101110","11101011110","11110101110","11010000100","11010010000","11010011100","11000111010"];function vo(t){const n=[104];for(const i of t){const a=i.charCodeAt(0);a<32||a>127||n.push(a-32)}let r=104;for(let i=1;i<n.length;i++)r+=i*n[i];return n.push(r%103),n.push(106),n.map(i=>jo[i]||"").join("")+"11"}var e=Is(),{Text:_r}=X,ea=({open:t,onClose:n,barcode:r,sku:i,productTitle:a})=>{const[s,l]=y.useState(12),d=(0,y.useRef)(null),g=bo(s),o=(0,y.useMemo)(()=>Array.from({length:g},(c,u)=>u),[g]);function p(){if(!d.current)return;const c=window.open("","_blank","width=800,height=900");if(!c)return;const u=`<!doctype html> 2<html lang="tr"> 3<head> 4<meta charset="utf-8" /> 5<title>Barkod Etiketleri â ${ko(a||r)}</title> 6<style> 7 @page { size: A4; margin: 8mm; } 8 body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; margin: 0; padding: 0; } 9 .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4mm; } 10 .label { 11 border: 1px dashed rgba(0,0,0,0.2); 12 padding: 4mm 3mm; 13 text-align: center; 14 page-break-inside: avoid; 15 border-radius: 2mm; 16 } 17 .label svg { max-width: 100%; height: 16mm; } 18 .meta { font-size: 9pt; margin-top: 1mm; word-break: break-all; } 19 .title { font-size: 8pt; opacity: 0.7; margin-bottom: 1mm; } 20 @media print { 21 .label { border: none; } 22 } 23</style> 24</head> 25<body> 26 ${d.current.innerHTML} 27 <script>window.onload = () => { window.print(); setTimeout(() => window.close(), 300); };<\/script> 28</body> 29</html>`;c.document.write(u),c.document.close()}return(0,e.jsx)(zt,{title:"Barkod Etiketi Yazdır",open:t,onCancel:n,width:680,footer:[(0,e.jsx)(w,{onClick:n,children:"Kapat"},"close"),(0,e.jsx)(w,{type:"primary",onClick:p,disabled:!r,children:"Yazdır"},"print")],children:(0,e.jsx)(m,{vertical:!0,gap:12,children:r?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(m,{gap:8,align:"center",wrap:"wrap",children:[(0,e.jsx)(_r,{children:"Kopya sayısı:"}),(0,e.jsx)(Ee,{min:1,max:200,value:s,onChange:c=>l(c??1)}),(0,e.jsx)(_r,{type:"secondary",style:{fontSize:12},children:"A4 sayfa baÅına 4 sütun yerleÅim"})]}),(0,e.jsx)("div",{ref:d,style:{maxHeight:420,overflow:"auto",border:"1px solid rgba(0,0,0,0.06)",padding:8,borderRadius:8},children:(0,e.jsx)("div",{className:"grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:o.map(c=>(0,e.jsxs)("div",{className:"label",style:{textAlign:"center",padding:8},children:[a&&(0,e.jsx)("div",{className:"title",style:{fontSize:10,opacity:.7,marginBottom:4},children:So(a,28)}),(0,e.jsx)(ta,{value:r}),(0,e.jsx)("div",{className:"meta",style:{fontSize:11,marginTop:4},children:r}),i&&(0,e.jsxs)("div",{className:"meta",style:{fontSize:10,opacity:.7},children:["SKU: ",i]})]},c))})})]}):(0,e.jsx)(V,{color:"red",children:"Bu üründe yazdırılacak bir birincil barkod yok."})})})};function So(t,n){return t.length>n?`${t.slice(0,n-1)}â¦`:t}var ta=({value:t,height:n=60,style:r})=>{const i=(0,y.useMemo)(()=>vo(t),[t]),a=1.5,s=i.length*a,l=[];let d=0;for(let g=0;g<i.length;g++)i[g]==="1"&&l.push((0,e.jsx)("rect",{x:d,y:0,width:a,height:n,fill:"#000"},g)),d+=a;return(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"100%",viewBox:`0 0 ${s} ${n}`,preserveAspectRatio:"none",style:{display:"block",maxWidth:"100%",...r},children:l})},ln=(t,n)=>t===0?n.colorError:t<=5?n.colorWarning:n.colorSuccess,To=t=>t===0?"red":t<=5?"orange":"green",na=(t,n)=>Yt(t,n)??0,ra=(t,n)=>Ut(t,n),ia=t=>t==="idefix"||t==="ikas"?"inventoryQuantity":"quantity",aa=(t,n)=>t[ia(n)]??0,on=t=>({barcode:"barcode",stockCode:"stockCode",sale:Vt[t].sale,list:Vt[t].list,shippingCost:"shippingCost",qty:ia(t)}
29),sa={unpublished:{label:"Yayında deÄil",tone:"default"},pending:{label:"Onay bekliyor",tone:"processing"},live:{label:"Yayında",tone:"success"},rejected:{label:"Reddedildi",tone:"error"},error:{label:"Hata",tone:"error"}},Eo=t=>(t??[]).map(n=>n?.message?.trim()).filter(n=>!!n),Io=new Set(["rejection","advisory","blacklist"]),Co=t=>(t??[]).flatMap(n=>{const r=n?.message?.trim();if(!r)return[];const i=n.kind&&Io.has(n.kind)?n.kind:"rejection",a=typeof n.at=="string"&&!Number.isNaN(new Date(n.at).getTime())?n.at:void 0,s=n.code?.trim()||void 0;return[{message:r,kind:i,...a?{at:a}:{},...s?{code:s}:{}}]}),la=t=>t.kind==="blacklist"?`Karaliste: ${t.message}`:t.message,oa=t=>t.filter(n=>n.kind!=="advisory").map(la),ca=t=>t.filter(n=>n.kind==="advisory"),wo=new Intl.DateTimeFormat("tr-TR",{timeZone:"Europe/Istanbul",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),pt=t=>{if(!t)return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:wo.format(n)},da=t=>{const n=t.priceSync?.confirmedAt??t.priceSync?.submittedAt??void 0,r=t.stockSync?.confirmedAt??t.stockSync?.queuedAt??void 0;return{...n&&pt(n)?{price:n}:{},...r&&pt(r)?{stock:r}:{}}},Po=t=>{let n;for(const r of t){const i=da(r);for(const a of[i.price,i.stock])a&&(!n||new Date(a).getTime()>new Date(n).getTime())&&(n=a)}return n},zo=t=>{const n=t??"live";return n!=="rejected"&&n!=="error"&&n!=="unpublished"},ua=(t,n,r)=>{let i=0,a=!1;return t.forEach((s,l)=>{zo(n[l])&&(a=!0,i+=aa(s,r))}),{stock:i,hasLive:a}},ma=(t,n,r)=>{if(!r)return t??"unpublished";const i=n.map(a=>a??t??"live");return i.includes("rejected")?"rejected":i.includes("error")?"error":i.every(a=>a==="live")?"live":i.includes("pending")?"pending":i.includes("live")?"live":"unpublished"},$r=t=>{const n=t.filter(r=>r>0);return n.length===0?null:{min:Math.min(...n),max:Math.max(...n)}},ya=t=>t.find(n=>n.merchantSku?.trim())?.merchantSku?.trim()??null,Or="hb-publish-submission",Ao=(t,n)=>n.length>0?!0:t!=null&&t!=="live",Lo=t=>{let n=null,r=null;for(const i of t){const a=i.product,s=a&&typeof a=="object"?a.lastSyncedAt:null;if(!s)continue;const l=new Date(s).getTime();Number.isNaN(l)||(n===null||l>n)&&(n=l,r=s)}return r},Jt=(t,n,r)=>{if(t!=="rejected"&&t!=="error"&&t!=="unpublished")return[];const i=r?.product;if(i&&typeof i=="object"){const a=Eo(i.rejectionReasons);if(a.length)return a}return n},Ro=["trendyol","hepsiburada","idefix","ideasoft"],Mo=["trendyol","idefix","hepsiburada","ideasoft"],Bo=["trendyol","hepsiburada","idefix","ideasoft"],Do="Bu pazaryerinin yayın akıÅı yakında",Gt=t=>Bo.includes(t)?"flow":Ro.includes(t)?"soon":"none",pa=t=>{const{marketplace:n,status:r,hasListings:i,listingUrl:a,ownStorefront:s}=t;if(i)return a?{kind:"open",label:s?"Sitede aç":"Pazaryerinde aç",href:a}:{kind:"none"};const l=Gt(n);if(l==="none")return{kind:"match",label:"EÅleÅtir"};const d=r==="rejected"||r==="error";return{kind:d?"retry":"publish",label:d?"Tekrar Yayınla":"Yayınla",...l==="soon"?{disabledReason:Do}:{}}},Fr=(t,n)=>t?.marketplaceConfigs?.[n]?.enabled===!0,cn=[{id:"ozet",label:"Ãzet",icon:Ds},{id:"bilgiler",label:"Bilgiler",icon:Hs},{id:"pazaryerleri",label:"Pazaryerleri",icon:_s},{id:"fiyat-gecmisi",label:"Fiyat geçmiÅi",icon:Bs},{id:"set",label:"Set ve varyant",icon:Ct},{id:"gecmis",label:"GeçmiÅ",icon:Os}],Nn={"stok-fiyat":"Stok ve fiyat",kimlik:"Kimlik ve lojistik"},Nr={"stok-fiyat":"bilgiler",kimlik:"bilgiler",gorseller:"ozet"},_o=new Set(cn.map(t=>t.id)),Kr=t=>!!t&&_o.has(t),$o={genel:"bilgiler",pazaryerleri:"pazaryerleri",gorseller:"ozet",gecmis:"gecmis",bundle:"set"};function Kn(t,n){if(t){const i=$o[t]??Nr[t];if(i)return i;if(Kr(t))return t}const r=n?n.replace(/^#/,"").replace(/^pdetail-/,""):"";return Kr(r)?r:Nr[r]??null}var dn=t=>`pdetail-${t}`;function Oo(t,n){const r=Kn(t,n);if(!r)return null;const i=t&&Kn(t)?t:(n??"").replace(/^#/,"").replace(/^pdetail-/,"");return r==="bilgiler"&&Object.keys(Nn).includes(i)?`pdetail-${i}`:dn(r)}function ha(){return typeof document>"u"?null:document.getElementById("root")}function Hr(t,n={}){return ga(dn(t),n)}function ga(t,n={}){if(typeof document>"u")return!1;const r=document.getElementById(t);if(!r)return!1;const i=ha(),a=n.offset??124,s=n.behavior??"smooth";if(!i)return window.scrollTo({top:r.getBoundingClientRect().top+window.scrollY-a,behavior:s}),!0;const l=r.getBoundingClientRect().top-i.getBoundingClientRect().top+i.scrollTop-a;return i.scrollTo({top:Math.max(0,l),behavior:s}),!0}var{Text:dt,Title:Fo}=X,No="Ãrün Åeridi";var Ko="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4Ij48cmVjdCB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgZmlsbD0iI2Y1ZjVmNSIvPjx0ZXh0IHg9IjUwJSIgeT0iNTUlIiBkb21pbmFudC1iYXNlbGluZT0ibWlkZGxlIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjYmZiZmJmIiBmb250LXNpemU9IjE0IiBmb250LWZhbWlseT0ic2Fucy1zZXJpZiI+Tm8gSW1hZ2U8L3RleHQ+PC9zdmc+",Ho=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.userAgent),Wr=t=>Ho?`â${t}`:`Ctrl+${t}`,Wo={success:"colorSuccess",processing:"colorInfo",warning:"colorWarning",error:"colorError",default:"colorTextQuaternary"},En=(t,n)=>(0,e.jsxs)(m,{justify:"space-between",align:"center",gap:16,children:[(0,e.jsx)("span",{children:t}),n&&(0,e.jsx)(dt,{type:"secondary",style:{fontSize:12},"aria-label":`kısayol ${n}`,children:n})]}),er=({children:t,...n})=>{const{token:r}=J.useToken();return(0,e.jsx)("div",{role:"region","aria-label":No,"data-testid":"detail-header-bar",...n,style:{position:"sticky",top:52,zIndex:20,minHeight:56,display:"flex",alignItems:"center",gap:16,margin:"0 -4px",padding:"8px 12px",background:r.colorBg
29Container,borderBottom:`1px solid ${r.colorBorderSecondary}`,boxShadow:r.boxShadowTertiary},children:t})},Go=t=>{const{message:n}=st.useApp(),{token:r}=J.useToken(),i=rn.useBreakpoint(),[a,s]=(0,y.useState)(!1),l=Hl(),d=Wl(t.productId),{canWrite:g,editing:o}=t,p=!g||o,c=p||t.publishActions.length===0,u=Object.keys(i).length>0,h=!u||!!i.xl,x=u&&!i.lg;Ji([{key:"p",handler:()=>g&&!o&&!c&&!Tt()&&t.onPublishShortcut()},{key:"m",handler:()=>!o&&!Tt()&&t.onMatch()},{key:"l",meta:!0,handler:()=>!Tt()&&t.onOpenActivity()}]);function b(){zt.confirm({title:"Ãrünü klonla?",content:"Yeni bir kopya oluÅturulacak (pazar listeleri olmadan).",okText:"Klonla",cancelText:"Vazgeç",onOk:async()=>{try{const C=await l.mutateAsync({id:t.productId});n.success("Ãrün klonlandı"),t.onCloned(C.id)}catch(C){n.error(`Klonlanamadı: ${C.message}`)}}})}function E(){d.mutate(void 0,{onSuccess:C=>{const L=Object.values(C.affected).reduce((R,N)=>R+N,0);n.success(`${L} listing pasifleÅtirildi`)},onError:C=>n.error(`PasifleÅtirilemedi: ${C.message}`)})}const S=t.publishActions.map(C=>({key:`publish-${C.key}`,"data-guide":`product-detail-publish-${C.key}`,label:C.label,disabled:C.disabled,onClick:C.onClick})),M=[...x?[{key:"publish",label:En("Yayınla","p"),disabled:c,children:g?S:[]}]:[],{key:"match",label:"EÅleÅtirme",children:[{key:"match-product",label:En("Ãrün EÅleÅtirme","m"),onClick:t.onMatch},{key:"match-variant",label:"Varyant Grubu",onClick:t.onOpenVariantGroup},{key:"match-set-products",label:"Set Ãrünler",onClick:t.onOpenSetProducts}]},{key:"barcode","data-guide":"product-detail-menu-barcode",label:"Barkod Etiketi Yazdır",onClick:()=>s(!0)},{key:"clone","data-guide":"product-detail-menu-clone",label:"Klonla",disabled:p,onClick:b},{key:"profit","data-guide":"product-detail-menu-profit",label:"Kâr / Marj Analizi",onClick:t.onOpenProfit},{key:"activity","data-guide":"product-detail-menu-activity",label:En("Aktivite Kaydı",Wr("L")),onClick:t.onOpenActivity},{key:"refresh",label:"Sayfayı Yenile",onClick:t.onRefresh},{type:"divider"},{key:"passivate","data-guide":"product-detail-menu-passivate",disabled:p,label:p?(0,e.jsx)(dt,{type:"danger",children:"Tüm Pazarlarda PasifleÅtir"}):(0,e.jsx)(Un,{title:"Tüm pazarlarda stoÄu sıfırla?",description:"Geri alınabilir ama tüm dashboard'ları etkiler.",okText:"PasifleÅtir",cancelText:"Vazgeç",onConfirm:E,children:(0,e.jsx)(dt,{type:"danger",children:"Tüm Pazarlarda PasifleÅtir"})})}],j=(0,e.jsxs)(m,{vertical:!0,style:{minWidth:0,flex:1},children:[(0,e.jsx)(Fo,{level:1,title:t.title,style:{margin:0,fontSize:16,lineHeight:"22px",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title}),!x&&(t.primaryBarcode||t.primarySku)&&(0,e.jsxs)(m,{gap:12,align:"center",style:{fontSize:13,lineHeight:"18px"},children:[t.primaryBarcode&&(0,e.jsx)(dt,{style:{fontFamily:r.fontFamilyCode,fontSize:13},copyable:{icon:(0,e.jsx)(_,{icon:yt,size:12}),tooltips:["Kopyala","Kopyalandı"]},children:t.primaryBarcode}),t.primarySku&&(0,e.jsxs)(dt,{type:"secondary",style:{fontSize:13},children:["SKU"," ",(0,e.jsx)(dt,{style:{fontFamily:r.fontFamilyCode,fontSize:13},copyable:{icon:(0,e.jsx)(_,{icon:yt,size:12}),tooltips:["Kopyala","Kopyalandı"]},children:t.primarySku})]})]})]}),k=h&&t.chips.length>0&&(0,e.jsx)(m,{gap:4,align:"center",role:"group","aria-label":"Pazaryeri durumları",style:{flexShrink:0},children:t.chips.map(({marketplace:C,status:L})=>{const R=Xe[C],N=sa[L],de=`${R.name}: ${N.label}`;return(0,e.jsx)(ne,{title:`${de} · karta git`,children:(0,e.jsxs)(w,{type:"text","aria-label":de,onClick:()=>t.onChipClick(C),style:{height:28,padding:"0 8px",gap:6},"data-testid":`header-chip-${C}`,children:[(0,e.jsx)(_i,{id:C,name:R.name,height:12}),(0,e.jsx)("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",background:r[Wo[N.tone]],display:"inline-block"}})]})},C)})}),z=(0,e.jsxs)(e.Fragment,{children:[!x&&(0,e.jsx)(ne,{title:`Aktivite kaydı (${Wr("L")})`,children:(0,e.jsx)(w,{"aria-label":"Aktivite kaydı",icon:(0,e.jsx)(_,{icon:$s,size:16}),onClick:t.onOpenActivity})}),(0,e.jsx)(Dn,{menu:{items:M},placement:"bottomRight",trigger:["click"],children:x?(0,e.jsx)(w,{"data-guide":"product-detail-menu","aria-label":"İÅlemler",icon:(0,e.jsx)(_,{icon:zi,size:16})}):(0,e.jsxs)(w,{"data-guide":"product-detail-menu","aria-label":"İÅlemler","aria-haspopup":"menu",children:["İÅlemler ",(0,e.jsx)(_,{icon:_n,size:14})]})}),!x&&(0,e.jsx)(Dn,{menu:{items:S}
29,placement:"bottomRight",trigger:["click"],disabled:c,children:(0,e.jsxs)(w,{"data-guide":"product-detail-publish","aria-label":"Yayınla","aria-haspopup":"menu",disabled:c,children:["Yayınla ",(0,e.jsx)(_,{icon:_n,size:14})]})}),!g&&(0,e.jsx)(ne,{title:"Görüntüleyici rolü deÄiÅiklik yapamaz",children:(0,e.jsx)(V,{style:{margin:0},children:"Görüntüleme yetkisi"})})]});return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(er,{children:[(0,e.jsx)(ne,{title:`${t.backLabel} sayfasına dön`,children:(0,e.jsx)(w,{type:"text","aria-label":`${t.backLabel} sayfasına dön`,icon:(0,e.jsx)(_,{icon:$n,size:18}),onClick:t.onBack,style:{width:32,height:32,minWidth:32,padding:0,flexShrink:0}})}),!x&&(0,e.jsx)("div",{"aria-hidden":!0,style:{width:40,height:40,borderRadius:r.borderRadius,overflow:"hidden",flexShrink:0,background:r.colorFillTertiary,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${r.colorBorderSecondary}`},children:t.imageUrl?(0,e.jsx)(It,{src:t.imageUrl,alt:"",width:40,height:40,preview:!1,style:{objectFit:"cover"},fallback:Ko}):(0,e.jsx)(_,{icon:Ai,size:18,color:r.colorTextTertiary})}),j,k,(0,e.jsx)(m,{gap:8,align:"center",style:{flexShrink:0},"data-guide":"pdetail-actions",children:z})]}),(0,e.jsx)(ea,{open:a,onClose:()=>s(!1),barcode:t.primaryBarcode||"",sku:t.primarySku||"",productTitle:t.title})]})},In=5e3,Yo=({productId:t,onSuccess:n,placeholder:r})=>{const{message:i}=st.useApp(),[a,s]=(0,y.useState)(""),l=Jl(t),d=Uo(a),g=a.trim(),o=g.length>In,p=!g||o||l.isPending;function c(){p||l.mutate({text:g,tags:d},{onSuccess:()=>{i.success("Not eklendi"),s(""),n?.()},onError:h=>{i.error(`Not eklenemedi: ${h.message}`)}})}function u(h){(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&(h.preventDefault(),c())}return(0,e.jsxs)(m,{vertical:!0,gap:6,style:{width:"100%"},children:[(0,e.jsx)(Le.TextArea,{value:a,onChange:h=>s(h.target.value),onKeyDown:u,placeholder:r||"Not ekle⦠(#etiket kullanabilirsin, â+Enter ile gönder)",autoSize:{minRows:2,maxRows:6},maxLength:In,showCount:!0,disabled:l.isPending}),(0,e.jsxs)(m,{justify:"space-between",align:"center",children:[(0,e.jsx)(m,{gap:4,wrap:"wrap",children:d.map(h=>(0,e.jsxs)(V,{color:"geekblue",style:{margin:0},children:["#",h]},h))}),(0,e.jsx)(ne,{title:o?`${In} karakter limiti aÅıldı`:"â+Enter ile gönder",children:(0,e.jsx)(w,{type:"primary",onClick:c,loading:l.isPending,disabled:p,children:"Not Ekle"})})]})]})};function Uo(t){const n=[],r=new Set,i=/#([a-zA-ZçÄıöÅüÃÄİÃÅÃ0-9_-]{1,32})/g;let a;for(;(a=i.exec(t))!==null;){const s=a[1];if(s&&!r.has(s)&&(r.add(s),n.push(s)),n.length>=10)break}return n}var{Text:jt,Title:Vo}=X,Gr={price_change:"Fiyat",stock_change:"Stok",status_change:"Durum",campaign_join:"Kampanya katıldı",campaign_leave:"Kampanya çıktı",buybox_won:"Buybox kazandı",buybox_lost:"Buybox kaybetti",listing_created:"Listing oluÅturuldu",listing_updated:"Listing güncellendi",content_update:"İçerik güncellendi",manual_annotation:"Not",commission_rate_changed:"Komisyon deÄiÅti",return_settlement_unmatched:"İade mali eÅleÅmedi",payment_order_reconciliation_mismatch:"Mutabakat uyuÅmadı"},qo={price_change:"gold",stock_change:"blue",status_change:"cyan",buybox_won:"green",buybox_lost:"red",listing_created:"green",listing_updated:"default",content_update:"purple",manual_annotation:"geekblue",commission_rate_changed:"orange"},Zo={user:"Kullanıcı",system:"Sistem",marketplace:"Marketplace"},Qo={user:"ð¤",system:"âï¸",marketplace:"ð"};function Xo(t){const n=Date.now(),r=new Date(t).getTime();if(!Number.isFinite(r))return t;const i=n-r;return i<6e4?"az önce":i<36e5?`${Math.floor(i/6e4)} dk önce`:i<864e5?`${Math.floor(i/36e5)} sa önce`:i<6048e5?`${Math.floor(i/864e5)} gün önce`:new Date(t).toLocaleDateString("tr-TR",{day:"2-digit",month:"short",year:"numeric"})}function Jo(t){return t.userId?typeof t.userId=="string"?t.userId.slice(-6):t.userId.name||t.userId.email||t.userId.id.slice(-6):Zo[t.source]||"Sistem"}function ec(t,n){return!n||!t.userId?!1:typeof t.userId=="string"?t.userId===n:t.userId.id===n}var tc=({productId:t,open:n,onClose:r,currentUserId:i,isAdmin:a})=>{const{message:s}=st.useApp(),[l,d]=(0,y.useState)(),[g,o]=(0,y.useState)(),p=qi(t,{eventType:l,s
29ource:g,limit:30},n),c=Xl(t),u=(0,y.useMemo)(()=>(p.data?.pages||[]).flatMap(x=>x.docs),[p.data]);function h(x){c.mutate({logId:x.id},{onSuccess:()=>s.success("Not silindi"),onError:b=>s.error(`Silinemedi: ${b.message}`)})}return(0,e.jsx)(qn,{title:(0,e.jsxs)(m,{justify:"space-between",align:"center",children:[(0,e.jsx)(Vo,{level:5,style:{margin:0},children:"Aktivite"}),(0,e.jsxs)(V,{children:[u.length," kayıt"]})]}),open:n,onClose:r,size:560,destroyOnClose:!0,children:(0,e.jsxs)(m,{vertical:!0,gap:12,children:[(0,e.jsx)(Yo,{productId:t,onSuccess:()=>p.refetch()}),(0,e.jsx)(Es,{style:{margin:"4px 0"}}),(0,e.jsxs)(m,{gap:8,wrap:"wrap",align:"center",children:[(0,e.jsx)(De,{placeholder:"Tüm olaylar",allowClear:!0,size:"small",style:{minWidth:180},value:l,onChange:d,options:Object.entries(Gr).map(([x,b])=>({value:x,label:b}))}),(0,e.jsx)(Vn,{size:"small",value:g??"all",onChange:x=>o(x==="all"?void 0:x),options:[{label:"Tümü",value:"all"},{label:"Kullanıcı",value:"user"},{label:"Sistem",value:"system"},{label:"Marketplace",value:"marketplace"}]})]}),p.isLoading?(0,e.jsx)(m,{justify:"center",align:"center",style:{minHeight:200},children:(0,e.jsx)(gt,{})}):u.length===0?(0,e.jsx)(fe,{description:"Bu ürün için kayıtlı aktivite yok"}):(0,e.jsxs)(m,{vertical:!0,gap:8,children:[u.map(x=>{const b=qo[x.eventType]||"default",E=Gr[x.eventType]||x.eventType,S=x.eventType==="manual_annotation",M=S&&(a||ec(x,i));return(0,e.jsx)("div",{style:{padding:10,borderRadius:8,border:"1px solid rgba(0,0,0,0.06)",background:S?"rgba(83,118,235,0.04)":"transparent"},children:(0,e.jsxs)(m,{justify:"space-between",align:"flex-start",gap:8,children:[(0,e.jsxs)(m,{vertical:!0,gap:4,style:{flex:1,minWidth:0},children:[(0,e.jsxs)(m,{gap:6,align:"center",wrap:"wrap",children:[(0,e.jsx)(V,{color:b,style:{margin:0,fontSize:10},children:E}),(0,e.jsxs)(jt,{type:"secondary",style:{fontSize:11},children:[Qo[x.source]," ",Jo(x)]}),(0,e.jsxs)(jt,{type:"secondary",style:{fontSize:11},children:["· ",Xo(x.createdAt)]})]}),(0,e.jsx)(jt,{style:{fontSize:13},children:x.summary}),S&&(()=>{const j=Array.isArray(x.metadata?.tags)?x.metadata.tags.filter(k=>typeof k=="string"):[];return j.length===0?null:(0,e.jsx)(m,{gap:4,wrap:"wrap",children:j.map(k=>(0,e.jsxs)(V,{color:"geekblue",style:{margin:0,fontSize:10},children:["#",k]},k))})})(),!S&&x.changes&&x.changes.length>0&&(0,e.jsxs)(m,{vertical:!0,gap:2,style:{marginTop:2},children:[x.changes.slice(0,3).map((j,k)=>(0,e.jsxs)(jt,{type:"secondary",style:{fontSize:11},children:[j.label||j.field,": ",(0,e.jsx)("code",{children:Yr(j.oldValue)})," â"," ",(0,e.jsx)("code",{children:Yr(j.newValue)})]},k)),x.changes.length>3&&(0,e.jsxs)(jt,{type:"secondary",style:{fontSize:11},children:["+",x.changes.length-3," alan daha"]})]})]}),M&&(0,e.jsx)(ne,{title:"Notu sil",children:(0,e.jsx)(Un,{title:"Notu sil?",okText:"Sil",cancelText:"Vazgeç",onConfirm:()=>h(x),children:(0,e.jsx)(w,{size:"small",type:"text",danger:!0,children:"â"})})})]})},x.id)}),p.hasNextPage&&(0,e.jsx)(w,{onClick:()=>p.fetchNextPage(),loading:p.isFetchingNextPage,block:!0,children:"Daha Eski Olayları Yükle"})]})]})})};function Yr(t){if(t==null)return"boÅ";if(typeof t=="string")return t.length>40?`${t.slice(0,40)}â¦`:t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{const n=JSON.stringify(t);return n?n.length>40?`${n.slice(0,40)}â¦`:n:"boÅ"}catch{return"karmaÅık deÄer"}}var fa=[{value:"packaging",label:"Ambalaj / Paketleme"},{value:"warehousing",label:"Depolama / Ardiye"},{value:"customs",label:"Gümrük Vergisi"},{value:"supplierShipping",label:"Nakliye (Tedarikçi)"},{value:"other",label:"DiÄer"}],nc=Object.fromEntries(fa.map(t=>[t.value,t.label])),Ur=[{value:"TRY",label:"TRY"},{value:"USD",label:"USD"},{value:"EUR",label:"EURO"}],xa=[{value:"marketplaceFirst",label:"Pazaryeri desisini kullan (varsa)"},{value:"manualAlways",label:"Her zaman girdiÄim desiyi kullan"}],rc=Object.fromEntries(xa.map(t=>[t.value,t.label]));var wt=t=>t.type==="other"?t.label||"DiÄer":nc[t.type]??t.label??t.type,{Text:ic}=X,Vr=({token:t})=>(0,e.jsx)("div",{style:{padding:"14px",textAlign:"center",background:t.colorBg
29Container},children:(0,e.jsx)(ic,{type:"secondary",children:"Ek gider eklenmemiÅ."})}),ac=(t,n)=>`listing:${t}:${n}`;function At(t){if(!t||!t.startsWith("listing:"))return null;const[,n,r]=t.split(":");return!it.includes(n??"")||!/^\d+$/.test(r??"")?null:{marketplace:n,index:Number(r)}}function un(t){return t.startsWith("listing:")?[]:t==="purchasePrice"?["purchasePrice","purchaseCurrency"]:[t]}function sc(t){const n=At(t);return n?[[n.marketplace,n.index]]:un(t).map(r=>[r])}function lc(t,n,r={}){const i=At(t);if(i){const s=n[i.marketplace];return Array.isArray(s)?{[i.marketplace]:s}:{}}const a={};for(const s of un(t))s==="stock"&&r.isBundle||(a[s]=n[s]);return a}function oc(t,n){const r=At(t);if(r)return Array.isArray(n)&&n[0]===r.marketplace&&Number(n[1])===r.index;const i=Array.isArray(n)?n[0]:n;return un(t).includes(i)}function cc(t,n,r){const i=At(t);if(i)return r.some(s=>s.marketplace===i.marketplace&&s.index===i.index);const a=un(t);return n.some(s=>a.includes(s))}var ka=(0,y.createContext)(null),dc=({value:t,children:n})=>(0,e.jsx)(ka.Provider,{value:t,children:n}),Cn=()=>{};function ht(t){const n=(0,y.useContext)(ka);return n?{isEditing:t!==void 0&&n.editingKey===t,anyEditing:n.editingKey!==null,canEdit:n.canWrite,saving:n.saving,start:()=>{t!==void 0&&n.start(t)},save:n.save,cancel:n.cancel}:{isEditing:!1,anyEditing:!1,canEdit:!1,saving:!1,start:Cn,save:Cn,cancel:Cn}}function uc(t){const n=t.target;return t.key==="Enter"&&!t.nativeEvent.isComposing&&n.tagName==="INPUT"&&n.getAttribute("role")!=="combobox"&&n.getAttribute("aria-expanded")!=="true"}var ba=t=>n=>{uc(n)&&(n.preventDefault(),t())},ja=({editKey:t,label:n})=>{const{token:r}=J.useToken(),{canEdit:i,isEditing:a,saving:s,start:l}=ht(t);return!i||a?null:(0,e.jsx)(ne,{title:"Düzenle",children:(0,e.jsx)(w,{type:"text","aria-label":`${n} düzenle`,disabled:s,onClick:l,icon:(0,e.jsx)(_,{icon:Ws,size:14,color:r.colorTextTertiary}),style:{width:24,height:20,minWidth:24,padding:0}})})},tr=({label:t})=>{const{saving:n,save:r,cancel:i}=ht();return Ji([{key:"Escape",allowInForm:!0,handler:()=>{!n&&!Tt()&&i()}},{key:"s",meta:!0,allowInForm:!0,handler:a=>{a.preventDefault(),!n&&!Tt()&&r()}}]),(0,e.jsxs)(m,{gap:6,style:{flexShrink:0},children:[(0,e.jsx)(ne,{title:"Kaydet (Enter)",children:(0,e.jsx)(w,{"data-guide":"product-detail-field-save",type:"primary","aria-label":`${t} kaydet`,loading:n,onClick:r,icon:(0,e.jsx)(_,{icon:Ks,size:16})})}),(0,e.jsx)(ne,{title:"Vazgeç (Esc)",children:(0,e.jsx)(w,{"data-guide":"product-detail-field-cancel","aria-label":`${t} düzenlemesinden vazgeç`,disabled:n,onClick:i,icon:(0,e.jsx)(_,{icon:Ns,size:16})})})]})},mc={fontSize:14,fontSizeSM:12,fontSizeLG:16,controlHeight:40,lineHeight:1.5};var wn=({children:t})=>{const{token:n}=J.useToken(),r=(0,y.useMemo)(()=>({token:{...mc},components:{Form:{labelFontSize:13,labelColor:n.colorTextSecondary,itemMarginBottom:20,verticalLabelPadding:"0 0 8px"},Card:{headerFontSize:17,headerHeight:60,bodyPadding:24},Descriptions:{labelBg:"transparent",labelColor:n.colorTextSecondary,itemPaddingBottom:12},Tag:{fontSizeSM:12}}}),[n.colorTextSecondary]);return(0,e.jsx)(Ii,{componentSize:"middle",variant:"filled",theme:r,children:t})},{Text:yc}=X,va=({children:t,action:n})=>{const{token:r}=J.useToken();return(0,e.jsxs)("div",{style:{color:r.colorTextSecondary,fontSize:13,height:20,marginBottom:8,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,e.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}),n]})},Hn=({label:t,children:n,dataField:r,extra:i,action:a,labelAction:s,onActivate:l,activateLabel:d,"data-guide":g})=>{const{token:o}=J.useToken(),[p,c]=(0,y.useState)(!1),u=(0,y.useId)(),h=!!l;return(0,e.jsxs)("div",{"data-field":r,style:{marginBottom:20,minWidth:0},children:[(0,e.jsx)(va,{action:s,children:t}),(0,e.jsxs)("div",{"data-guide":g,onClick:h?x=>{const b=x.target.closest('button, a, [role="button"]');b&&b!==x.currentTarget.firstElementChild||l()}:void 0,onMouseEnter:h?()=>c(!0):void 0,onMouseLeave:h?()=>c(!1):void 0,style:{minHeight:o.controlHeight,padding:`${Math.max(0,(o.controlHeight-o.fontSize*o.lineHeight)/2-1)}px 12px`,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",borderRadius:o.borderRadius,background:h&&p?o.colorFillSecondary:o.colorFillTertiary,cursor:h?"text":void 0,transition:`background ${o.motionDurationMid}`,fontVariantNumeric:"tabular-nums",wordBreak:"break-word"},children:[(0,e.jsx)("div",{...h&&{role:"button",tabIndex:0,"aria-label":d,"aria-describedby":u,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),l())}},style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:(0,e.jsx)("span",{id:u,style:{display:"contents"},children:n})}),a]}),i&&(0,e.jsx)(yc,{type:"secondary",style:{display:"block",marginTop:6,fontSize:o.fontSizeSM},children:i})]})},Ke=({editKey:t,children:n,edit:r,readOnly:i,ariaLabel:a,...s})=>{const{isEditing:l,canEdit:d,saving:g,save:o,start:p}=ht(t),c=a??(typeof s.label=="string"?s.label:"Alan"),u=(0,y.useRef)(null);if((0,y.useEffect)(()=>
29{if(!l)return;const h=u.current?.querySelector('input:not([type="hidden"]):not([disabled]), textarea:not([disabled]), [contenteditable="true"]');if(h&&(h.focus(),h instanceof HTMLInputElement||h instanceof HTMLTextAreaElement))try{const x=h.value.length;h.setSelectionRange(x,x)}catch{}},[l]),!l){const h=d&&!i&&!g;return(0,e.jsx)(Hn,{...s,onActivate:h?p:void 0,activateLabel:`${c} düzenle`,children:n})}return(0,e.jsx)("div",{ref:u,"data-field":s.dataField,"data-inline-editing":"true",onKeyDown:ba(o),children:(0,e.jsxs)(m,{gap:8,align:"flex-start",children:[(0,e.jsx)("div",{style:{flex:1,minWidth:0},children:r}),(0,e.jsx)("div",{style:{paddingTop:28},children:(0,e.jsx)(tr,{label:c})})]})})},{Text:je,Title:qr}=X;var Wn=(t,n,r)=>{const i=new Map,a=(l,d)=>{Number.isFinite(d)&&i.set(l,(i.get(l)??0)+d)},s=Be(n);t!=null&&a(s,Number(t));for(const l of r??[])a(Be(l?.currency),Number(l?.amount));return[...i.entries()].map(([l,d])=>({currency:l,total:d})).sort((l,d)=>l.currency===s?-1:d.currency===s?1:0)},Sa=t=>t.length===0?"â":t.map(n=>he(n.total,n.currency)).join(" + "),Pn=Ui(2,2),pc=Ui(0,3);var hc={mode:"fixed",type:"packaging",amount:0,currency:"TRY"},Zr=(t,n)=>{const r=Number(n?.currentPrice??0),i=Number(t??0);if(!Number.isFinite(r)||r<=0||!Number.isFinite(i)||i<=0)return 0;const a=r*i,s=Number(n?.vatRate),l=Il.includes(s)?s:20,d=n?.vatIncluded===!0?a/(1+l/100):a;return Math.round(d*1e4)/1e4},Ta=t=>Number(t??0).toLocaleString("tr-TR",{maximumFractionDigits:3}),Qr=t=>`${t.name} · ${Yi(t.currentPrice??0,t.currency)}/${t.unit}`,gc=({fullLabel:t,...n})=>(0,e.jsx)(ne,{title:t,mouseEnterDelay:.3,children:(0,e.jsx)(De,{...n})}),fc=(t,n)=>
29(t.mode??"fixed")==="fixed"&&(n.mode??"fixed")==="fixed"&&wt(t).trim().toLocaleLowerCase("tr-TR")===wt(n).trim().toLocaleLowerCase("tr-TR")&&Number(t.amount)===Number(n.amount)&&Be(t.currency)===Be(n.currency),xc=(t,n)=>{const r=t?.supplyItem,i=n.get(sn(r)??"");return i||(r&&typeof r=="object"?{id:r.id,name:r.name??"Sarf malzemesi",unit:r.unit??""}:null)},kc=({product:t,form:n,catalogPricing:r,identity:i,onOpenPriceHistory:a,supplyItems:s=[],supplyItemsLoading:l=!1,supplyItemsError:d=!1,onConvertExpense:g})=>{const{token:o}=J.useToken(),p=rn.useBreakpoint(),c=Object.keys(p).length===0||!!p.xl,u=ht("purchasePrice"),h=ht("additionalExpenses"),x=W.useWatch("purchasePrice",n),b=W.useWatch("purchaseCurrency",n),E=W.useWatch("additionalExpenses",{form:n,preserve:!0}),S=u.isEditing?x:t.purchasePrice,M=u.isEditing?Be(b):Be(t.purchaseCurrency),j=h.isEditing?E:t.additionalExpenses,k=Wn(S,M,j),z=y.useMemo(()=>new Map(s.map(v=>[v.id,v])),[s]),C=t.stock??0,L=ln(C,o),R=a?(0,e.jsx)(w,{type:"link",size:"small",onClick:a,style:{padding:0,height:"auto"},children:"GeçmiÅ"}):null,N=(0,e.jsxs)("div",{"data-testid":"unit-cost",style:{padding:16,borderRadius:o.borderRadiusLG,border:`1px solid ${o.colorPrimaryBorder}`,background:o.colorPrimaryBg},children:[(0,e.jsxs)(m,{justify:"space-between",align:"start",wrap:"wrap",gap:8,children:[(0,e.jsxs)(m,{vertical:!0,gap:2,children:[(0,e.jsx)(je,{strong:!0,children:"Birim maliyet"}),(0,e.jsx)(je,{type:"secondary",children:"AlıŠ+ ek giderler"})]}),(0,e.jsx)(m,{vertical:!0,align:"end",gap:0,children:k.length===0?(0,e.jsx)(je,{strong:!0,style:{fontSize:o.fontSizeHeading4,color:o.colorPrimary,fontVariantNumeric:"tabular-nums"},children:"â"}):k.map(v=>(0,e.jsx)(je,{strong:!0,style:{fontSize:o.fontSizeHeading4,color:o.colorPrimary,fontVariantNumeric:"tabular-nums"},children:he(v.total,v.currency)},v.currency))})]}),k.length>1&&(0,e.jsx)(je,{type:"secondary",style:{fontSize:o.fontSizeSM},children:"Kalemler farklı para birimlerinde; tek bir toplam için kur gerekiyor."})]}),de=(0,e.jsxs)(m,{justify:"space-between",align:"center",wrap:"wrap",gap:8,children:[(0,e.jsx)(qr,{level:4,style:{margin:0,fontSize:o.fontSize,fontWeight:600},children:"Ek giderler"}),(0,e.jsxs)(m,{align:"center",gap:8,children:[!h.isEditing&&(j?.length??0)>0&&(0,e.jsxs)(je,{type:"secondary",style:{fontVariantNumeric:"tabular-nums"},children:["Toplam ",Sa(Wn(null,M,j))]}),h.isEditing?(0,e.jsx)(tr,{label:"Ek giderler"}):(0,e.jsx)(ja,{editKey:"additionalExpenses",label:"Ek giderler"})]})]}),H=(0,e.jsx)("div",{style:{borderRadius:o.borderRadius,border:`1px solid ${o.colorBorderSecondary}`,overflow:"hidden"},children:t.additionalExpenses?.length?t.additionalExpenses.map((v,A,ye)=>{const K=v.mode==="supply",ee=K?xc(v,z):null;return(0,e.jsxs)(m,{justify:"space-between",align:"center",gap:12,style:{padding:"12px 16px",borderBottom:A<ye.length-1?`1px solid ${o.colorBorderSecondary}`:"none"},children:[(0,e.jsxs)(m,{vertical:!0,gap:2,children:[(0,e.jsx)(je,{children:K?ee?.name??"Sarf malzemesi":wt(v)}),K&&(0,e.jsx)(je,{type:"secondary",style:{fontSize:o.fontSizeSM},children:`${Ta(v.quantity)} ${ee?.unit??""}`.trim()})]}),(0,e.jsxs)(je,{strong:!0,style:{fontVariantNumeric:"tabular-nums"},children:[Sn(v.currency),Ae(v.amount)," ",(0,e.jsx)(je,{type:"secondary",children:Be(v.currency)})]})]},v.id||A)}):(0,e.jsx)(Vr,{token:o})}),q=(0,e.jsx)(W.List,{name:"additionalExpenses",children:(v,{add:A,remove:ye})=>(0,e.jsxs)(m,{vertical:!0,gap:12,children:[v.length===0&&(0,e.jsx)("div",{style:{borderRadius:o.borderRadius,border:`1px solid ${o.colorBorderSecondary}`,overflow:"hidden"},children:(0,e.jsx)(Vr,{token:o})}),v.map((K,ee)=>(0,e.jsx)(W.Item,{noStyle:!0,shouldUpdate:(pe,re)=>pe.additionalExpenses?.[K.name]!==re.additionalExpenses?.[K.name],children:({getFieldValue:pe})=>{const re=pe(["additionalExpenses",K.name]),xe=re?.mode??"fixed",ge=sn(re?.supplyItem),ie=z.get(ge??""),ue=(Z,me)=>n.setFieldValue(["additionalExpenses",K.name,Z],me),we=(Z,me=ie)=>ue("amount",Zr(Z,me));return(0,e.jsxs)(_e,{gutter:[16,0],align:"top",wrap:!0,style:{padding:8,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadius},children:[(0,e.jsx)(F,{span:24,children:(0,e.jsx)(W.Item,{name:[K.name,"mode"],label:"Satır tipi",style:{marginBottom:8},children:(0,e.jsx)(Vn,{options:[{value:"fixed",label:"Serbest tutar"},{value:"supply",label:"Sarf malzemesi"}],onChange:Z=>{Z==="fixed"?(ue("supplyItem",void 0),ue("quantity",void 0)):(ue("type","packaging"),ue("label",void 0),ue("supplyItem",void 0),ue("quantity",1),ue("amount",0))}})})}),xe==="supply"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(F,{xs:24,sm:12,children:(0,e.jsx)(W.Item,{name:[K.name,"supplyItem"],label:"Sarf tanımı",rules:[{required:!0,message:"Sarf malzemesi seçin"}],style:{marginBottom:8},children:(0,e.jsx)(gc,{fullLabel:ie?Qr(ie):void 0,showSearch:!0,loading:l,optionFilterProp:"label",placeholder:"Sarf malzemesi seçin","aria-label":`Sarf tanımı (${ee+1}. satır)`,notFoundContent:l?void 0:"Sarf tanımı yok",options:s.filter(Z=>!Z.archived||Z.id===ge).map(Z=>({value:Z.id,label:Qr(Z)})),onChange:Z=>{const me=z.get(Z);ue("currency",me?.currency??"TRY"),we(re?.quantity??1,me)}})})}),(0,e.jsx)(F,{xs:24,sm:12,children:(0,e.jsx)(W.Item,{name:[K.name,"quantity"],label:"Adet / miktar",rules:[{required:!0,message:"Miktar girin"},{type:"number",min:.001,message:"Miktar 0'dan büyük olmalı"}],style:{marginBottom:8}
29,children:(0,e.jsx)(Ee,{min:.001,precision:3,...pc,step:.001,"aria-label":`Adet / miktar (${ee+1}. satır)`,suffix:ie?.unit,style:{width:"100%"},onChange:Z=>we(Z)})})}),(0,e.jsx)(F,{xs:24,sm:20,children:(0,e.jsx)(W.Item,{label:ie?.vatIncluded?"KDV hariç net":"Otomatik tutar",style:{marginBottom:8},extra:ie?.currentPriceEffectiveFrom?`Birim fiyat ${Yi(ie.currentPrice??0,ie.currency)} · ${ze(ie.currentPriceEffectiveFrom)} tarihinden beri`:void 0,children:(0,e.jsx)(Le,{readOnly:!0,"aria-label":`Otomatik tutar (${ee+1}. satır)`,value:he(re?.amount??0,ie?.currency??re?.currency)})})})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(F,{xs:24,sm:12,children:(0,e.jsx)(W.Item,{name:[K.name,"type"],label:"Tür",rules:[{required:!0,message:"Gider türü seçin"}],style:{marginBottom:8},children:(0,e.jsx)(De,{options:fa,onChange:Z=>{Z!=="other"&&n.setFieldValue(["additionalExpenses",K.name,"label"],void 0)}})})}),(0,e.jsx)(F,{xs:24,sm:12,children:(0,e.jsx)(W.Item,{noStyle:!0,shouldUpdate:(Z,me)=>Z.additionalExpenses?.[K.name]?.type!==me.additionalExpenses?.[K.name]?.type,children:({getFieldValue:Z})=>{const me=Z(["additionalExpenses",K.name,"type"])==="other";return(0,e.jsx)(W.Item,{name:[K.name,"label"],label:"Açıklama",rules:me?[{required:!0,message:"Açıklama girin"}]:void 0,style:{marginBottom:8},children:(0,e.jsx)(Le,{disabled:!me,maxLength:80})})}})}),(0,e.jsx)(F,{xs:12,sm:10,children:(0,e.jsx)(W.Item,{name:[K.name,"amount"],label:"Tutar",rules:[{required:!0,message:"Tutar girin"},{type:"number",min:0,message:"Negatif olamaz"}],style:{marginBottom:8},children:(0,e.jsx)(Ee,{precision:2,min:0,...Pn,style:{width:"100%"}})})}),(0,e.jsx)(F,{xs:12,sm:10,children:(0,e.jsx)(W.Item,{name:[K.name,"currency"],label:"Para birimi",rules:[{required:!0,message:"Para birimi seçin"}],style:{marginBottom:8},children:(0,e.jsx)(De,{options:Ur})})})]}),(0,e.jsx)(F,{xs:24,sm:4,children:(0,e.jsx)(W.Item,{label:" ",colon:!1,style:{marginBottom:8},children:(0,e.jsx)(ne,{title:"Gideri sil",children:(0,e.jsx)(w,{type:"text",danger:!0,"aria-label":`Gideri sil (${ee+1}. satır)`,icon:(0,e.jsx)(_,{icon:Ms,size:16}),onClick:()=>ye(K.name)})})})}),xe==="fixed"&&g&&(0,e.jsx)(F,{span:24,children:(0,e.jsx)(Un,{title:"Sarf malzemesine dönüÅtürülsün mü?",description:"Sarf malzemesi tanımı hemen oluÅturulur; ürünü kaydetmeseniz de ayarlarda kalır.",okText:"DönüÅtür",cancelText:"Vazgeç",onConfirm:async()=>{if(re)try{const Z=await g(re),me=n.getFieldValue("additionalExpenses")??[];n.setFieldValue("additionalExpenses",me.map(ae=>fc(ae,re)?{...ae,mode:"supply",type:"packaging",label:void 0,supplyItem:Z.id,quantity:1,amount:Zr(1,Z),currency:Z.currency}:ae))}catch{}},children:(0,e.jsx)(w,{type:"link",size:"small",style:{paddingInline:0},children:"Sarf malzemesine dönüÅtür"})})})]})}},K.key)),(0,e.jsx)("div",{children:(0,e.jsx)(w,{type:"dashed",icon:(0,e.jsx)(_,{icon:an,size:14}),onClick:()=>A({...hc}),children:"Gider ekle"})})]})}),Y={span:24},I=Be(t.purchaseCurrency),P=(0,e.jsxs)(_e,{gutter:[16,0],children:[(0,e.jsx)(F,{...Y,children:(0,e.jsxs)(Ke,{"data-guide":"product-detail-stock",editKey:"stock",label:"Ana stok",dataField:"stock",readOnly:!!t.isBundle,edit:(0,e.jsx)(W.Item,{name:"stock",label:"Ana stok",rules:[{type:"number",min:0,message:"Stok negatif olamaz"}],children:(0,e.jsx)(Ee,{"data-guide":"product-detail-stock-input",min:0,precision:0,autoFocus:!0,style:{width:"100%"}})}),children:[(0,e.jsx)("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",background:L,display:"inline-block"}}),(0,e.jsx)(je,{strong:!0,style:{color:L},children:C}),t.isBundle&&(0,e.jsx)(ne,{title:"BileÅen stoklarından hesaplanır",children:(0,e.jsx)(V,{color:"geekblue",style:{margin:0},children:"Otomatik"})})]})}),(0,e.jsx)(F,{...Y,children:(0,e.jsxs)(Ke,{"data-guide":"product-detail-purchase-price",editKey:"purchasePrice",label:"AlıŠfiyatı",dataField:"purchasePrice",action:R,edit:(0,e.jsx)(W.Item,{label:"AlıŠfiyatı",required:!0,extra:R,children:(0,e.jsxs)(Ht.Compact,{style:{width:"100%"},children:[(0,e.jsx)(W.Item,{name:"purchasePrice",noStyle:!0,rules:[{type:"number",min:0,message:"AlıŠfiyatı negatif olamaz"}],children:(0,e.jsx)(Ee,{precision:2,min:0,...Pn,autoFocus:!0,"aria-label":"AlıŠfiyatı",suffix:Sn(M),style:{width:"100%"}})}),(0,e.jsx)(W.Item,{name:"purchaseCurrency",noStyle:!0,rules:[{required:!0,message:"Para birimi zorunlu"}],children:(0,e.jsx)(De,{"aria-label":"AlıŠpara birimi","data-field":"purchaseCurrency",options:Ur,style:{width:96,flexShrink:0}})})]})}),children:[(0,e.jsx)(je,{strong:!0,style:{color:o.colorSuccess},children:t.purchasePrice!=null?`${Sn(I)}${Ae(t.purchasePrice)}`:"â"}),I!=="TRY"&&(0,e.jsxs)(je,{type:"secondary",children:["(",I,")"]})]})}),(0,e.jsx)(F,{...Y,children:(0,e.jsx)(Ke,{editKey:"shippingCost",label:"Kargo ücreti",dataField:"shippingCost",edit:(0,e.jsx)(W.Item,{name:"shippingCost",label:"Kargo ücreti",rules:[{type:"number",min:0,message:"Kargo ücreti negatif olamaz"}],children:(0,e.jsx)(Ee,{precision:2,min:0,...Pn,suffix:"âº",autoFocus:!0,style:{width:"100%"}})}),children:(0,e.jsx)(je,{strong:!0,children:t.shippingCost!=null?`âº${Ae(t.shippingCost)}`:"â"})})})]});return(0,e.jsxs)(_e,{gutter:[24,24],children:[(0,e.jsxs)(F,{xs:24,lg:8,xl:5,"data-testid":"stock-pricing-fields",children:[(0,e.jsx)(qr,{level:4,style:{margin:"0 0 16px",fontSize:o.fontSizeLG,fontWeight:600},children:"Stok ve fiyat"}),P]}),i&&(0,e.jsx)(F,{xs:24,lg:16,xl:10,"data-testid":"stock-pricing-identity",children:i}),(0,e.jsx)(F,{xs:24,xl:i?9:19,children:(0,e.jsxs)(m,{vertical:!0,gap:20,"data-testid":"stock-pricing-costs",style:c?{borderLeft:`1px solid ${o.colorBorderSecondary}`,paddingLeft:24,height:"100%"}:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:20},children:[r,(0,e.jsxs)(m,{vertical:!0,gap:12,"data-field":"additionalExpenses",children:[de,h.isEditing&&d&&(0,e.jsx)(ce,{type:"error",showIcon:!0,title:"Sarf tanımları yüklenemedi",description:"Serbest gider ekleyebilirsiniz; sarf seçimi için daha sonra yeniden deneyin."}),h.isEditing?q:H]}),N]})})]})},{Title:bc,Text:nt}=X,jc={override:"Manuel override",product:"Ãrün / Settlement",category:"Kategori oranı",tenant:"Ayarlarınızdan",default:"Varsayılan oran"},vc=({productId:t,open:n,onClose:r,focusMarketplace:i,additionalExpenses:a=[],supplyItems:s=[]})=>{const{data:l,isLoading:d,isError:g}=Zl(t,n),o=y.useMemo(()=>new Map(s.map(c=>[c.id,c])),[s]),p=l?.listings.some(c=>c.netProfit!=null)?eo(l.missingInputs):[];return(0,e.jsx)(qn,{"data-guide":"product-detail-profit-drawer",title:"Kâr / Marj Analizi",open:n,onClose:r,size:620,destroyOnClose:!0,children:d?(0,e.jsx)(m,{justify:"center",align:"center",style:{minHeight:200},children:(0,e.jsx)(gt,{})}):g||!l?(0,e.jsx)(ce,{type:"error",title:"Kâr verisi yüklenemedi",description:"Lütfen biraz sonra tekrar deneyin."}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(Me,{size:"small",style:{marginBottom:16},children:[(0,e.jsxs)(_e,{gutter:16,children:[(0,e.jsx)(F,{span:8,children:(0,e.jsx)(kt,{title:"Ortalama Marj",value:Ot(l.summary.avgMarginPct),styles:{content:{color:Ft(l.summary.avgMarginPct)==="red"?"#ff4d4f":Ft(l.summary.avgMarginPct)==="orange"?"#fa8c16":"#52c41a"}}})}),(0,e.jsx)(F,{span:8,children:(0,e.jsx)(kt,{title:"En İyi",value:Ot(l.summary.bestMarginPct),styles:{content:{color:"#52c41a"}}})}),(0,e.jsx)(F,{span:8,children:(0,e.jsx)(kt,{title:"En Kötü",value:Ot(l.summary.worstMarginPct),styles:{content:{color:Ft(l.summary.worstMarginPct)==="red"?"#ff4d4f":"#fa8c16"}}})})]}),(0,e.jsxs)(_e,{gutter:16,style:{marginTop:12},children:[(0,e.jsx)(F,{span:12,children:(0,e.jsx)(kt,{title:"Toplam Tahmini Ciro",value:Pe(l.summary.totalEstimatedRevenue)})}),(0,e.jsx)(F,{span:12,children:(0,e.jsx)(kt,{title:"Toplam Tahmini Kâr",value:Pe(l.summary.totalEstimatedProfit)})})]})]}),l.unconvertibleCurrencies.length>0&&(0,e.jsx)(ce,{type:"warning",showIcon:!0,title:"Bazı para birimleri dönüÅtürülemedi",description:`DönüÅtürülemeyen kurlar: ${l.unconvertibleCurrencies.join(", ")}`,style:{marginBottom:12}}),p.length>0&&(0,e.jsx)(ce,{type:"warning",showIcon:!0,title:"Kâr kısmen hesaplandı",description:p.join(" · "),style:{marginBottom:12}}),l.totalPurchaseCostTRY!=null&&(0,e.jsx)(Me,{size:"small",style:{marginBottom:12},children:(0,e.jsxs)(m,{justify:"space-between",align:"center",children:[(0,e.jsx)(nt,{children:"Toplam birim maliyet (alıŠ+ ek giderler):"}),(0,e.jsx)(nt,{strong:!0,children:Pe(l.totalPurchaseCostTRY)})]})}),a.some(c=>c.mode==="supply")&&(0,e.jsx)(Me,{size:"small",title:"Sarf malzemeleri",style:{marginBottom:12},children:(0,e.jsx)(m,{vertical:!0,gap:6,children:a.filter(c=>c.mode==="supply").map((c,u)=>{const h=o.get(sn(c.supplyItem)??"")??(typeof c.supplyItem=="object"?c.supplyItem:null);return(0,e.jsx)(Ye,{label:`${h?.name??wt(c)} · ${Ta(c.quantity)} ${h?.unit??""}`.trim(),value:`â${he(c.amount??0,c.currency)}`},c.id??`${h?.id??"supply"}-${u}`)})})}),l.listings.length===0?(0,e.jsx)(fe,{description:"Hesaplanacak listing yok"}):(0,e.jsx)(m,{vertical:!0,gap:10,children:l.listings.map((c,u)=>{const h=i&&c.marketplace===i;return(0,e.jsxs)(Me,{size:"small",style:{borderColor:h?"#1677ff":void 0,borderWidth:h?2:void 0},children:[(0,e.jsxs)(m,{justify:"space-between",align:"center",style:{marginBottom:8},children:[(0,e.jsx)(bc,{level:5,style:{margin:0},children:Vl[c.marketplace]}),(0,e.jsxs)(V,{color:Ft(c.marginPct),style:{margin:0},children:[Ot(c.marginPct)," marj · ",Pe(c.netProfit)," kâr"]})]}),(0,e.jsxs)(m,{vertical:!0,gap:4,children:[(0,e.jsx)(Ye,{label:"SatıÅ",value:Pe(c.salePrice)}),(0,e.jsx)(Ye,{label:Rr(c).label,value:`â${Pe(Rr(c).amount)}`}),(0,e.jsx)(Ye,{label:`Komisyon (%${c.commissionRate} · ${jc[c.commissionSource]})`,value:`â${Pe(c.commissionAmount)}`}),c.realizedRateSkipped===!0&&(0,e.jsx)(nt,{type:"secondary",style:{fontSize:11},children:"Hesap kesimindeki oran farklı fiyattaki satıÅa ait, bu fiyat için kullanılmadı."}),c.serviceFee!=null&&(0,e.jsx)(Ye,{label:"Hizmet bedeli",value:`â${Pe(c.serviceFee)}`}),c.stopajAmount!=null&&(0,e.jsx)(Ye,{label:Ql(c.stopajRate),value:`â${Pe(c.stopajAmount)}`}),(0,e.jsx)(Ye,{label:"Kargo",value:`â${Pe(c.shippingCost)}`}),(0,e.jsx)(Ye,{label:"Maliyet",value:`â${Pe((c.purchasePriceTRY??0)+c.additionalExpensesTRY)}`})]}),Mr(c)&&(0,e.jsx)(nt,{type:"warning",style:{fontSize:12,display:"block",marginTop:6},children:Ul(Mr(c),c.salePrice)}),c.warnings.length>0&&(0,e.jsx)(m,{vertical:!0,gap:2,style:{marginTop:6},children:c.warnings.map(x=>(0,e.jsxs)(nt,{type:"warning",style:{fontSize:11},children:["â ",x]},x))})]},`${c.marketplace}-${u}`)})})]})})},Ye=({label:t,value:n})=>(0,e.jsxs)(m,{justify:"space-between",align:"center",children:[(0,e.jsx)(nt,{type:"secondary",style:{fontSize:12},children:t}),(0,e.jsx)(nt,{style:{fontSize:12},children:n})]}),{Text:Nt,Title:Sc}
29=X,Xr="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCI+PHJlY3Qgd2lkdGg9IjQ4IiBoZWlnaHQ9IjQ4IiBmaWxsPSIjZjVmNWY1Ii8+PC9zdmc+",Tc=({productId:t,hideWhenEmpty:n})=>{const r=nn(),i=Ti(),{data:a,isLoading:s,isError:l}=Vi(t);if(s)return(0,e.jsx)(Me,{size:"small",children:(0,e.jsx)(m,{justify:"center",align:"center",style:{minHeight:80},children:(0,e.jsx)(gt,{size:"small"})})});if(l)return(0,e.jsx)(Me,{size:"small",children:(0,e.jsx)(ce,{type:"error",title:"BaÄlı set ürünler yüklenemedi",showIcon:!0})});const d=a?.parents||[];return n&&d.length===0?null:(0,e.jsx)(Me,{size:"small",title:(0,e.jsxs)(m,{justify:"space-between",align:"center",children:[(0,e.jsxs)(m,{gap:8,align:"center",children:[(0,e.jsx)(Sc,{level:5,style:{margin:0},children:"Bu Ãrünü İçeren Set Ãrünler"}),(0,e.jsx)(V,{children:d.length})]}),a?.truncated&&(0,e.jsx)(ne,{title:"Sadece ilk 50 sonuç gösteriliyor",children:(0,e.jsx)(V,{color:"orange",children:"+50"})})]}),children:d.length===0?(0,e.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:"Bu ürünü içeren bir set ürün yok"}):(0,e.jsx)(m,{vertical:!0,gap:8,children:d.map(g=>(0,e.jsxs)(m,{gap:10,align:"center",style:{padding:8,borderRadius:8,cursor:"pointer",border:"1px solid rgba(0,0,0,0.06)",background:g.componentBlocking?"rgba(245,34,45,0.04)":"transparent"},onClick:()=>r(`/products/${g.id}`,{state:{from:i.pathname}}),children:[(0,e.jsx)(It,{src:g.primaryImage||Xr,width:48,height:48,alt:g.title,preview:!1,fallback:Xr,style:{objectFit:"cover",borderRadius:6}}),(0,e.jsxs)(m,{vertical:!0,gap:2,style:{flex:1,minWidth:0},children:[(0,e.jsx)(Nt,{strong:!0,ellipsis:!0,style:{fontSize:13},children:g.title}),(0,e.jsxs)(m,{gap:6,wrap:"wrap",align:"center",children:[(0,e.jsxs)(V,{color:"geekblue",style:{margin:0,fontSize:10},children:[g.thisComponentQuantity," adet kullanılıyor"]}),(0,e.jsxs)(Nt,{type:"secondary",style:{fontSize:11},children:["Set stok: ",g.currentBundleStock??"â",g.stockCap!=null&&` / ${g.stockCap} cap`]})]}),g.componentBlocking&&(0,e.jsx)(Nt,{type:"danger",style:{fontSize:11},children:"Bu bileÅen stoÄu nedeniyle set ürün satılamıyor"})]}),(0,e.jsx)(Nt,{type:"secondary",style:{fontSize:16},children:"â"})]},g.id))})})},Et=Si(xs(),1),{Title:Ec}=X,Jr={trendyolProduct:{key:"trendyol",label:"Trendyol",field:"quantity"},hepsiburadaProduct:{key:"hepsiburada",label:"Hepsiburada",field:"stock"},idefixProduct:{key:"idefix",label:"Idefix",field:"inventoryQuantity"},ikasProduct:{key:"ikas",label:"ikas",field:"inventoryQuantity"},ideasoftProduct:{key:"ideasoft",label:"IdeaSoft",field:"stockAmount"},productDetail:{key:"main",label:"Ana Stok",field:"stock"}},Ic=["main","trendyol","hepsiburada","idefix","ikas","ideasoft"],Cc=5,wc=100;function Pc(t){if(t==null||t==="")return;const n=Number(t);return Number.isFinite(n)?n:void 0}function zc(t,n){return t==="main"?n.colorPrimary:Ri(t)}var Ac=({productId:t})=>{const{token:n}=J.useToken(),r=qi(t,{limit:wc},!0),{data:i,hasNextPage:a,isFetchingNextPage:s,fetchNextPage:l}=r,d=i?.pages.length??0;(0,y.useEffect)(()=>{a&&!s&&d<Cc&&l()},[a,s,d,l]);const g=(0,y.useMemo)(()=>i?.pages.flatMap(u=>u.docs)??[],[i]),{chartData:o,series:p}=(0,y.useMemo)(()=>{const u=g.slice().sort((S,M)=>new Date(S.createdAt).getTime()-new Date(M.createdAt).getTime()),h={},x=new Set,b=[];for(const S of u){const M=Jr[S.entityType];if(!M)continue;const j=S.changes?.find(z=>z.field===M.field);if(!j)continue;const k=Pc(j.newValue);k!==void 0&&(h[M.key]=k,x.add(M.key),b.push({ts:new Date(S.createdAt).getTime(),time:(0,Et.default)(S.createdAt).format("DD/MM HH:mm"),fullTime:(0,Et.default)(S.createdAt).format("DD/MM/YYYY HH:mm"),...h}))}const E={};return Object.values(Jr).forEach(S=>{E[S.key]=S.label}),{chartData:b,series:Ic.filter(S=>x.has(S)).map(S=>({key:S,label:E[S]}))}},[g]);let c;return r.isLoading?c=(0,e.jsx)(m,{justify:"center",align:"center",style:{minHeight:300},children:(0,e.jsx)(gt,{})}):r.isError?c=(0,e.jsx)(ce,{type:"error",title:"Stok grafiÄi yüklenemedi",showIcon:!0}):o.length<2||p.length===0?c=(0,e.jsx)(fe,{description:"Grafik için yeterli stok deÄiÅikliÄi bulunmuyor",style:{padding:"32px 0"}}):c=(0,e.jsx)(Ni,{width:"100%",height:340,children:(0,e.jsxs)(Ki,{data:o,margin:{top:10,right:12,left:0,bottom:0},children:[(0,e.jsx)(Oi,{strokeDasharray:"3 3",stroke:n.colorBorderSecondary}),(0,e.jsx)(Fi,{dataKey:"time",tick:{fontSize:11},minTickGap:24}),(0,e.jsx)(Hi,{tick:{fontSize:11},width:44,allowDecimals:!1}),(0,e.jsx)($i,{labelFormatter:(u,h)=>h?.[0]?.payload?.fullTime??u,contentStyle:{borderRadius:n.borderRadius,border:`1px solid ${n.colorBorderSecondary}`,fontSize:12}}),(0,e.jsx)(Zs,{wrapperStyle:{fontSize:12}}),p.map(u=>(0,e.jsx)(On,{type:"stepAfter",dataKey:u.key,name:u.label,stroke:zc(u.key,n),strokeWidth:2,dot:{r:2},connectNulls:!0},u.key))]})}),(0,e.jsxs)(m,{vertical:!0,gap:12,children:[(0,e.jsxs)(m,{align:"center",gap:8,children:[(0,e.jsx)(_,{icon:Ct,size:16,color:n.colorTextSecondary}),(0,e.jsx)(Ec,{level:4,style:{margin:0,fontSize:n.fontSize,fontWeight:600},children:"Stok deÄiÅimi"})]}),c]})},{Text:Kt}=X,ei="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MCIgaGVpZ2h0PSI4MCI+PHJlY3Qgd2lkdGg9IjgwIiBoZWlnaHQ9IjgwIiBmaWxsPSIjZjVmNWY1Ii8+PC9zdmc+",ti={manual:"default",trendyol:"orange",hepsiburada:"red",idefix:"volcano",ikas:"cyan",ideasoft:"purple",ai_generated:"geekblue"},ni={manual:"Manuel",trendyol:"TY",hepsiburada:"HB",idefix:"IDX",ikas:"ikas",ideasoft:"IdeaSoft",ai_generated:"AI"},Lc=({productId:t,initialImages:n,maxImages:r=30})=>{const{message:i}=st.useApp(),{token:a}=J.useToken(),[s,l]=(0,y.useState)(()=>ri(n||[])),[d,g]=(0,y.useState)(null),[o,p]=(0,y.useState)(null),[c,u]=(0,y.useState)(""),[h,x]=(0,y.useState)(!1),b=Kl(t),E=ql(t),S=Yl(t),M=(0,y.useMemo)(()=>ri(n||[]),[n]);(0,y.useEffect)(()=>
29{l(I=>ii(I,M)?I:M),p(null)},[M]);const j=o!==null?s[o]:null,k=(0,y.useMemo)(()=>!ii(s,M),[s,M]);function z(I){l(I)}function C(){const I=c.trim();if(I){if(s.length>=r){i.warning(`En fazla ${r} görsel ekleyebilirsiniz`);return}if(s.some(P=>P.url===I)){i.info("Bu URL zaten ekli");return}z([...s,{url:I,order:s.length,source:"manual"}]),u(""),x(!1)}}function L(I){g(I)}function R(I){if(d===null||d===I)return;const P=[...s],[v]=P.splice(d,1);v&&(P.splice(I,0,v),P.forEach((A,ye)=>A.order=ye),g(null),z(P))}function N(I){const P=s.filter((v,A)=>A!==I);P.forEach((v,A)=>v.order=A),z(P),p(null)}function de(I){if(I===0)return;const P=[...s],[v]=P.splice(I,1);v&&(P.unshift(v),P.forEach((A,ye)=>A.order=ye),z(P),p(0))}function H(I,P){const v=[...s],A=v[I];A&&(v[I]={...A,altText:P},z(v))}function q(){b.mutate({images:s},{onSuccess:()=>i.success("Görseller kaydedildi"),onError:I=>i.error(`Kaydedilemedi: ${I.message}`)})}function Y(I){S.mutate({imageIndex:I},{onSuccess:P=>{H(I,P.altText),i.success("Alt metin üretildi")},onError:P=>i.error(`AI baÅarısız: ${P.message}`)})}return(0,e.jsxs)(m,{vertical:!0,gap:12,children:[(0,e.jsxs)(m,{justify:"space-between",align:"center",gap:8,wrap:"wrap",children:[(0,e.jsx)(Kt,{type:"secondary",children:`${s.length} / ${r} görsel`}),(0,e.jsxs)(m,{gap:8,wrap:"wrap",children:[(0,e.jsx)(w,{icon:(0,e.jsx)("span",{"aria-hidden":!0,children:"+"}),onClick:()=>x(!0),children:"URL ekle"}),(0,e.jsx)(w,{onClick:()=>E.mutate(void 0,{onSuccess:I=>{const P=Object.values(I.added).reduce((v,A)=>v+A,0);i.success(P>0?`${P} yeni görsel eklendi`:"Yeni görsel yok")},onError:I=>i.error(`Sync baÅarısız: ${I.message}`)}),loading:E.isPending,children:"Pazaryerinden çek"}),(0,e.jsx)(w,{type:"primary",onClick:q,loading:b.isPending,disabled:!k,children:"Görselleri kaydet"})]})]}),s.length===0?(0,e.jsx)(fe,{description:"Henüz görsel yok"}):(0,e.jsxs)(m,{vertical:!0,gap:12,children:[s.length>0&&s[0]?.url&&(0,e.jsx)(ce,{type:"info",showIcon:!0,style:{padding:"4px 12px"},title:(0,e.jsxs)(Kt,{children:["İlk görsel ürünün ",(0,e.jsx)("strong",{children:"ana görseli"})," olarak kullanılır. Sürükleyerek sıralamayı deÄiÅtirebilirsin."]})}),(0,e.jsx)(m,{gap:8,wrap:"wrap",children:s.map((I,P)=>{const v=P===0;return(0,e.jsxs)("div",{draggable:!0,onDragStart:()=>L(P),onDragOver:A=>A.preventDefault(),onDrop:()=>R(P),onClick:()=>p(P),style:{width:96,height:96,position:"relative",border:P===o?"2px solid #1677ff":v?"2px solid #faad14":"1px solid rgba(0,0,0,0.1)",borderRadius:8,overflow:"hidden",cursor:"grab",opacity:d===P?.4:1},title:I.altText||I.url,children:[(0,e.jsx)(It,{src:I.url,alt:I.altText||`Görsel ${P+1}`,width:96,height:96,style:{objectFit:"cover"},fallback:ei,preview:!1}),v&&(0,e.jsx)("div",{style:{position:"absolute",top:4,left:4,background:"#faad14",color:"#fff",borderRadius:4,padding:"0 4px",fontSize:10,fontWeight:600},children:"â"}),I.source&&(0,e.jsx)("div",{style:{position:"absolute",bottom:4,right:4},children:(0,e.jsx)(V,{color:ti[I.source],style:{margin:0,padding:"0 4px"},children:ni[I.source]})})]},I.url)})}),j&&o!==null&&(0,e.jsx)(Me,{size:"small",style:{borderColor:a.colorPrimaryBorder},children:(0,e.jsxs)(m,{gap:12,align:"flex-start",children:[(0,e.jsx)(It,{src:j.url,width:120,height:120,style:{objectFit:"cover",borderRadius:8},fallback:ei}),(0,e.jsxs)(m,{vertical:!0,gap:8,style:{flex:1,minWidth:0},children:[(0,e.jsxs)(m,{gap:4,wrap:"wrap",align:"center",children:[j.source&&(0,e.jsx)(V,{color:ti[j.source],style:{margin:0},children:ni[j.source]}),o===0&&(0,e.jsx)(V,{color:"gold",style:{margin:0},children:"Ana Görsel"})]}),(0,e.jsx)(Le,{placeholder:"Alt metin (SEO/eriÅilebilirlik)",value:j.altText||"",onChange:I=>H(o,I.target.value),maxLength:500}),(0,e.jsx)(Kt,{type:"secondary",style:{fontSize:11,wordBreak:"break-all"},children:j.url}),(0,e.jsxs)(m,{gap:6,wrap:"wrap",children:[o!==0&&(0,e.jsx)(ne,{title:"Bu görseli ana görsel yap (en baÅa taÅı)",children:(0,e.jsx)(w,{size:"small",onClick:()=>de(o),children:"â Ana Görsel Yap"})}),(0,e.jsx)(w,{size:"small",onClick:()=>Y(o),loading:S.isPending,children:"⨠AI Alt Metin"}),(0,e.jsx)(w,{size:"small",danger:!0,onClick:()=>N(o),children:"Sil"})]})]})]})})]}),(0,e.jsxs)(zt,{title:"URL ile Görsel Ekle",open:h,onCancel:()=>x(!1),onOk:C,okText:"Ekle",cancelText:"Vazgeç",children:[(0,e.jsx)(Le,{placeholder:"https://...",value:c,onChange:I=>u(I.target.value),onPressEnter:C}),(0,e.jsx)(Kt,{type:"secondary",style:{marginTop:8,display:"block"},children:"Sunucu SSRF guard ile özel IP/local URL'leri reddeder."})]})]})};function ri(t){const n=t.filter(r=>!!r?.url);return n.sort((r,i)=>(r.order??0)-(i.order??0)),n.map((r,i)=>({...r,order:i}
29))}function ii(t,n){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]?.url!==n[r]?.url||(t[r]?.altText||"")!==(n[r]?.altText||"")||(t[r]?.order??0)!==(n[r]?.order??0))return!1;return!0}var{Title:Rc}=X,Ue=({section:t,count:n,extra:r,bodyPadding:i,anchor:a=!0,children:s})=>{const{token:l}=J.useToken(),d=cn.find(o=>o.id===t),g=dn(t);return(0,e.jsx)(Me,{id:a?g:void 0,"data-guide":g,"aria-labelledby":`${g}-title`,role:"region",title:(0,e.jsxs)(m,{align:"center",gap:8,children:[d&&(0,e.jsx)(_,{icon:d.icon,size:16,color:l.colorTextSecondary}),(0,e.jsx)(Rc,{id:`${g}-title`,level:3,style:{margin:0,fontSize:l.fontSizeLG,fontWeight:600},children:d?.label??t}),n!=null&&(0,e.jsx)(V,{style:{margin:0},children:n})]}),extra:r,style:{borderRadius:l.borderRadiusLG,border:`1px solid ${l.colorBorderSecondary}`,boxShadow:l.boxShadowTertiary,scrollMarginTop:a?124:void 0},styles:{header:{borderBottom:"none"},body:i!==void 0?{padding:i}:{paddingTop:4}},children:s})},{Text:ai,Title:Mc}=X,Bc="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4Ij48cmVjdCB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgZmlsbD0iI2Y1ZjVmNSIvPjx0ZXh0IHg9IjUwJSIgeT0iNTUlIiBkb21pbmFudC1iYXNlbGluZT0ibWlkZGxlIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjYmZiZmJmIiBmb250LXNpemU9IjE0IiBmb250LWZhbWlseT0ic2Fucy1zZXJpZiI+Tm8gSW1hZ2U8L3RleHQ+PC9zdmc+";var Dc=({title:t,images:n,primaryBarcode:r,primarySku:i,summaryItems:a,badges:s,showAddMarketplace:l,onAddMarketplace:d,gallery:g})=>{const{token:o}=J.useToken(),p=rn.useBreakpoint(),c=Object.keys(p).length===0||!!p.lg,[u,h]=(0,y.useState)(!1),x=n[0],b=(0,e.jsx)("div",{style:{aspectRatio:"1 / 1",width:"100%",maxWidth:200,borderRadius:o.borderRadiusLG,overflow:"hidden",background:o.colorFillQuaternary,border:`1px solid ${o.colorBorderSecondary}`,display:"flex",alignItems:"center",justifyContent:"center"},children:x?(0,e.jsx)(It,{src:x.url,alt:x.altText||t,width:"100%",height:"100%",style:{objectFit:"contain"},fallback:Bc}):(0,e.jsxs)(m,{vertical:!0,align:"center",gap:6,children:[(0,e.jsx)(_,{icon:Ai,size:40,color:o.colorTextQuaternary}),(0,e.jsx)(ai,{type:"secondary",children:"Görsel yok"})]})}),E=r?(0,e.jsxs)(m,{align:"center",gap:8,style:{width:300,maxWidth:"100%",padding:"6px 8px",borderRadius:o.borderRadiusLG,border:`1px solid ${o.colorBorderSecondary}`,background:o.colorFillQuaternary},children:[(0,e.jsxs)(m,{vertical:!0,align:"center",style:{flex:1,minWidth:0,background:"#fff",borderRadius:o.borderRadiusSM,padding:"4px 8px"},children:[(0,e.jsx)("div",{style:{width:"100%",height:30},"aria-hidden":!0,children:(0,e.jsx)(ta,{value:r,height:30,style:{height:"100%"}})}),(0,e.jsx)("span",{"data-testid":"summary-barcode",style:{color:"#000",fontFamily:"monospace",fontSize:o.fontSizeSM,letterSpacing:1},children:r})]}),(0,e.jsx)(ne,{title:"Barkod etiketi yazdır",children:(0,e.jsx)(w,{type:"text","aria-label":"Barkod etiketi yazdır",icon:(0,e.jsx)(_,{icon:Gs,size:16}),onClick:()=>h(!0)})})]}):null;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Ue,{section:"ozet",children:(0,e.jsxs)(_e,{gutter:[32,24],children:[(0,e.jsx)(F,{xs:24,lg:12,children:(0,e.jsxs)(m,{gap:20,wrap:"wrap",align:"flex-start",children:[(0,e.jsx)("div",{style:{width:200,maxWidth:"100%",flexShrink:0},children:b}),(0,e.jsxs)(m,{vertical:!0,gap:12,style:{flex:1,minWidth:220},children:[(0,e.jsx)(Ke,{editKey:"title",label:"Ãrün adı",dataField:"title",edit:(0,e.jsx)(W.Item,{name:"title",label:"Ãrün adı",rules:[{required:!0,whitespace:!0,message:"Ãrün adı zorunlu"}],children:(0,e.jsx)(Le,{maxLength:300,autoFocus:!0,style:{fontWeight:600}})}),children:(0,e.jsx)(ai,{strong:!0,children:t})}),s,(0,e.jsx)(Ci,{bordered:!0,size:"small",column:1,items:a}),E,l&&(0,e.jsx)("div",{children:(0,e.jsx)(w,{type:"dashed",icon:(0,e.jsx)(_,{icon:an,size:14}),onClick:d,children:"Pazaryeri Ekle"})})]})]})}),(0,e.jsx)(F,{xs:24,lg:12,children:(0,e.jsxs)(m,{vertical:!0,gap:12,"data-field":"images","data-testid":"summary-gallery",style:c?{borderLeft:`1px solid ${o.colorBorderSecondary}`,paddingLeft:32,height:"100%"}:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:20},children:[(0,e.jsxs)(m,{align:"center",gap:8,children:[(0,e.jsx)(Mc,{level:4,style:{margin:0,fontSize:o.fontSize,fontWeight:600},children:"Görseller"}),(0,e.jsx)(V,{style:{margin:0},children:n.length})]}),g]})})]})}),r&&(0,e.jsx)(ea,{open:u,onClose:()=>h(!1),barcode:r,sku:i??void 0,productTitle:t})]})},_c=cn.filter(t=>t.id!=="set"&&t.id!=="ozet").map(t=>
29t.id),$c=()=>(0,e.jsxs)(m,{vertical:!0,gap:16,style:{width:"100%",padding:"0 4px"},"aria-busy":"true",children:[(0,e.jsxs)(er,{"aria-busy":!0,children:[(0,e.jsx)(Re.Avatar,{active:!0,shape:"square",size:40}),(0,e.jsxs)(m,{vertical:!0,gap:6,style:{flex:1,minWidth:0},children:[(0,e.jsx)(Re.Input,{active:!0,size:"small",style:{width:280,height:18}}),(0,e.jsx)(Re.Input,{active:!0,size:"small",style:{width:180,height:14}})]}),(0,e.jsxs)(m,{gap:8,children:[(0,e.jsx)(Re.Button,{active:!0,style:{width:96}}),(0,e.jsx)(Re.Button,{active:!0,style:{width:96}})]})]}),(0,e.jsx)(Re.Input,{active:!0,block:!0,size:"small",style:{height:36}}),(0,e.jsxs)(m,{vertical:!0,gap:24,style:{minWidth:0},children:[(0,e.jsx)(Ue,{section:"ozet",anchor:!1,children:(0,e.jsxs)(_e,{gutter:[24,20],children:[(0,e.jsx)(F,{xs:24,md:8,lg:6,children:(0,e.jsx)(Re.Node,{active:!0,style:{width:200,height:200,maxWidth:"100%"}})}),(0,e.jsx)(F,{xs:24,md:16,lg:18,children:(0,e.jsx)(Re,{active:!0,paragraph:{rows:6},title:!1})})]})}),_c.map(t=>(0,e.jsx)(Ue,{section:t,anchor:!1,children:(0,e.jsx)(Re,{active:!0,paragraph:{rows:4},title:!1})},t))]})]}),nr="productPurchase",mn={all:["cost-price-history"],timeline:(t,n,r,i)=>["cost-price-history","timeline",Wt(t,n),r,i],list:(t,n,r)=>["cost-price-history","list",Wt(t,n),r],recalc:(t,n)=>["cost-price-history","recalc",Wt(t,n)]},Oc=["done","failed","superseded","idle"],Fc=t=>t===void 0||Oc.includes(t);function Nc(t,n){const{tenant:r}=Qe(),i=qt(n.range),a=mn.timeline(t??"",r?.id??null,n.range,n.includePlanned);return Zn({queryKey:a,queryFn:()=>Ze.request(Ie.PRODUCT_DETAIL.COST_TIMELINE,{id:t,...i.from?{from:i.from}:{},to:i.to,includePlanned:n.includePlanned}),enabled:(n.enabled??!0)&&!!t,staleTime:3e4,refetchOnWindowFocus:!1,placeholderData:(s,l)=>Jn(l?.queryKey,a)?s:void 0})}function si(t,n){const{tenant:r}=Qe(),i=n.limit??20,a=mn.list(t??"",r?.id??null,n.page);return Zn({queryKey:a,queryFn:()=>Ze.request(Ie.PRODUCT_DETAIL.COST_PRICE_LIST,{where:{subjectType:{equals:nr},productDetail:{equals:t}},sort:"-effectiveFrom",page:n.page,limit:i}),enabled:(n.enabled??!0)&&!!t,staleTime:3e4,refetchOnWindowFocus:!1,placeholderData:(s,l)=>Jn(l?.queryKey,a)?s:void 0})}function Kc(t,n=!0){const{tenant:r}=Qe();return Zn({queryKey:mn.recalc(t??"",r?.id??null),queryFn:()=>Ze.request(Ie.PRODUCT_DETAIL.COST_RECALC_STATUS,{subjectId:t,subjectType:nr}),enabled:n&&!!t,refetchOnWindowFocus:!1,refetchInterval:i=>Fc(i.state.data?.status)?!1:4e3})}function Hc(){return Pi({mutationFn:t=>Ze.request(Ie.PRODUCT_DETAIL.COST_PRICE_PREVIEW,t)})}function Wc(t){const n=ws(),{tenant:r}=Qe();return Pi({mutationFn:i=>{if(i.operation==="delete")return Ze.request(Ie.PRODUCT_DETAIL.COST_PRICE_DELETE,{entryId:i.entryId});const a=i.draft;if(!a)throw new Error("Taslak olmadan fiyat kaydı yazılamaz");const s={price:a.price,currency:a.currency,effectiveFrom:zl(a.effectiveFrom),...a.note?{note:a.note}:{},...i.overwrite?{overwrite:!0}:{}};return i.operation==="update"?Ze.request(Ie.PRODUCT_DETAIL.COST_PRICE_UPDATE,{entryId:i.entryId,...s}):Ze.request(Ie.PRODUCT_DETAIL.COST_PRICE_CREATE,{subjectType:nr,id:t,...s})},onSuccess:()=>{n.invalidateQueries({queryKey:mn.all}),n.invalidateQueries({queryKey:["product-details-single",t,r?.id]}),n.invalidateQueries({queryKey:["product-detail"]})}})}var Gc={all:["sale-price-history"],list:(t,n,r,i,a)=>["sale-price-history",Wt(t,n),r,i,a]};function Yc(t,n){const{tenant:r}=Qe(),i=qt(n.range),a=Gc.list(t??"",r?.id??null,n.range,n.marketplace??null,n.listingId??null);return Cs({queryKey:a,queryFn:({pageParam:s})=>Ze.request(Ie.PRODUCT_DETAIL.SALE_PRICE_HISTORY,{id:t,...i.from?{from:i.from}:{},to:i.to,...n.marketplace?{marketplace:n.marketplace}:{},...n.listingId?{listingId:n.listingId}:{},limit:n.limit??50,...s?{cursor:s}:{}}),initialPageParam:null,getNextPageParam:s=>s.hasMore?s.nextCursor:void 0,enabled:(n.enabled??!0)&&!!t,staleTime:3e4,refetchOnWindowFocus:!1,placeholderData:(s,l)=>Jn(l?.queryKey,a)?s:void 0})}var{Text:li}=X,Uc=({range:t,onRangeChange:n,plannedCount:r,showPlanned:i,onShowPlannedChange:a,rangeLabel:s,busy:l})=>{const{token:d}=J.useToken();return(0,e.jsxs)(m,{vertical:!0,gap:8,children:[(0,e.jsxs)(m,{align:"center",gap:16,wrap:"wrap",children:[(0,e.jsx)(Vn,{value:t,onChange:n,options:Pl,"aria-label":"Grafik zaman aralıÄı"}),r>0&&(0,e.jsx)(wi,{checked:i,onChange:g=>a(g.target.checked),children:`Planlı kayıtları göster · ${r}`}),l&&(0,e.jsx)(li,{type:"secondary","aria-live":"polite",style:{fontSize:d.fontSizeSM},children:"Güncelleniyorâ¦"})]}),(0,e.jsx)(li,{type:"secondary",style:{fontSize:d.fontSizeSM},children:s})]})},{Text:Vc}=X,qc=({series:t,selected:n,onChange:r,narrow:i,colorFor:a})=>{const{token:s}=J.useToken();return t.length===0?null:i?(0,e.jsx)(De,{mode:"multiple",value:[...n],onChange:r,style:{width:"100%"},maxTagCount:0,maxTagPlaceholder:()=>`Seriler · ${n.length} seçili`,placeholder:"Seriler · 0 seçili","aria-label":"Grafikte gösterilecek seriler",options:t.map(l=>({value:l.key,label:l.label}))}):(0,e.jsx)(m,{gap:16,wrap:"wrap",role:"group","aria-label":"Grafikte gösterilecek seriler",children:t.map(l=>(0,e.jsx)(wi,{checked:n.includes(l.key),onChange:d=>{r(d.target.checked?[...n,l.key]:n.filter(g=>g!==l.key))},children:(0,e.jsxs)(m,{align:"center",gap:8,style:{minWidth:0},children:[(0,e.jsx)("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:2,flexShrink:0,background:a(l)}}),(0,e.jsx)(Vc,{ellipsis:!0,style:{fontSize:s.fontSize},children:l.label})]})},l.key))})},{Text:vt}=X,oi=({ts:t,rows:n,variant:r})=>{const{token:i}=J.useToken();return t===null||n.length===0?r==="inline"?(0,e.jsx)("div",{style:{minHeight:84,padding:12},children:(0,e.jsx)(vt,{type:"secondary",children:"Bir nokta seçin."})}):null:(0,e.jsxs)("div",{style:{minWidth:220,padding:12,background:i.colorBgElevated,border:`1px solid ${i.colorBorderSecondary}
29`,borderRadius:i.borderRadiusLG,boxShadow:r==="overlay"?i.boxShadowSecondary:void 0,...r==="inline"?{minHeight:84}:{}},children:[(0,e.jsxs)(vt,{type:"secondary",style:{fontSize:i.fontSizeSM},children:[Qn(t).format("D MMMM YYYY · HH:mm")," â İstanbul"]}),(0,e.jsx)(m,{vertical:!0,gap:10,style:{marginTop:8},children:n.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsxs)(m,{align:"center",justify:"space-between",gap:12,children:[(0,e.jsxs)(m,{align:"center",gap:8,style:{minWidth:0},children:[(0,e.jsx)("span",{"aria-hidden":!0,style:{width:10,height:10,flexShrink:0,borderRadius:2,background:a.planned?"transparent":a.color,border:`2px solid ${a.color}`}}),(0,e.jsx)(vt,{ellipsis:!0,style:{minWidth:0},children:a.label})]}),(0,e.jsx)(vt,{strong:!0,style:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:he(a.value,a.currency)})]}),(0,e.jsxs)(vt,{type:"secondary",style:{fontSize:i.fontSizeSM},children:[a.planned?"Planlı · ":"",a.detail]})]},a.seriesKey))})]})},{Text:Zc}=X,ci=40;function di(t,n){for(let r=t.length-1;r>=0;r-=1){const i=t[r];if(i&&i.ts<=n)return i}}var Qc=({series:t,currency:n,narrow:r,todayTs:i,colorFor:a,reducedMotion:s})=>{const{token:l}=J.useToken(),{rechartsTheme:d}=ml(),[g,o]=(0,y.useState)(!1),[p,c]=(0,y.useState)(null),u=(0,y.useMemo)(()=>t.flatMap(k=>k.points),[t]),h=(0,y.useMemo)(()=>jl(u,i),[u,i]),x=(0,y.useMemo)(()=>t.map(k=>{const z=k.points[k.points.length-1],C=z&&!z.planned&&z.ts<i?[...k.points,{...z,ts:i}]:k.points,L=C.findIndex(R=>R.planned);return L<0?{series:k,data:C,plannedData:null}:L===0?{series:k,data:[],plannedData:C}:{series:k,data:C.slice(0,L),plannedData:C.slice(L-1)}}),[t,i]),b=(0,y.useMemo)(()=>u.length===0?0:Math.max(...u.map(k=>Math.abs(k.value)))<20?2:0,[u]),E=(0,y.useMemo)(()=>p===null?[]:x.map(({series:k,data:z,plannedData:C})=>{const L=(C?di(C,p):void 0)??di(z,p);return L?{seriesKey:k.key,label:k.label,value:L.value,currency:k.currency,detail:L.detail,color:a(k),planned:L.planned}:null}).filter(k=>k!==null),[p,x,a]),S=(0,y.useMemo)(()=>u.slice().sort((k,z)=>k.ts-z.ts).map((k,z)=>({key:`${k.ts}-${z}`,date:at(new Date(k.ts).toISOString()),value:he(k.value,n),state:k.planned?"Planlı":"Yürürlükte"})),[u,n]);if(u.length===0)return(0,e.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:"Bu aralıkta gösterilecek fiyat kaydı yok"});const M=r?240:320,j=`${n} para biriminde ${t.length} seri, ${u.length} fiyat noktası.`;return(0,e.jsxs)(m,{vertical:!0,gap:8,children:[(0,e.jsxs)(m,{align:"center",justify:"space-between",gap:12,wrap:"wrap",children:[(0,e.jsx)(Zc,{type:"secondary",style:{fontSize:l.fontSizeSM},children:n}),(0,e.jsx)(w,{type:"link",style:{padding:0,minHeight:44},"aria-expanded":g,onClick:()=>o(k=>!k),children:g?"Tabloyu gizle":"Grafik verilerini tablo olarak göster"})]}),(0,e.jsx)("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:j}),(0,e.jsx)("div",{style:{width:"100%",height:M},"data-testid":`price-chart-${n}`,children:(0,e.jsx)(Ni,{width:"100%",height:"100%",children:(0,e.jsxs)(Ki,{margin:{top:20,right:56,bottom:8,left:4},onMouseMove:k=>{const z=k.activeLabel,C=typeof z=="number"?z:null;c(L=>L===C?L:C)},onMouseLeave:()=>c(null),children:[(0,e.jsx)(Oi,{stroke:d.cartesianGridColor,strokeDasharray:"3 3"}),(0,e.jsx)(Fi,{dataKey:"ts",type:"number",scale:"time",domain:h??["dataMin","dataMax"],tick:{fill:d.tickColor,fontSize:12},tickFormatter:k=>Qn(k).format("DD.MM")}
29),(0,e.jsx)(Hi,{tick:{fill:d.tickColor,fontSize:12},width:72,domain:["auto","auto"],tickFormatter:k=>he(k,n,{fractionDigits:b})}),h&&h[1]>i&&(0,e.jsx)(Zi,{x1:i,x2:h[1],fill:l.colorFillAlter,fillOpacity:1}),(0,e.jsx)(Ml,{x:i,stroke:d.referenceLineColor,strokeDasharray:"4 4",label:{value:"Bugün",position:"top",fill:d.textColor,fontSize:12}}),(0,e.jsx)($i,{content:r?(()=>null):(0,e.jsx)(oi,{ts:p,rows:E,variant:"overlay"}),cursor:{stroke:d.referenceLineColor,strokeDasharray:"3 3"}}),x.map(({series:k,data:z})=>(0,e.jsx)(On,{data:z,dataKey:"value",name:k.label,type:"stepAfter",stroke:a(k),strokeWidth:k.kind==="cost"?2.5:1.75,dot:z.length<=ci,activeDot:{r:4},connectNulls:!1,isAnimationActive:!s},k.key)),x.map(({series:k,plannedData:z})=>z?(0,e.jsx)(On,{data:z,dataKey:"value",legendType:"none",type:"stepAfter",stroke:a(k),strokeWidth:k.kind==="cost"?2.5:1.75,strokeDasharray:"6 4",dot:z.length<=ci,activeDot:{r:4},connectNulls:!1,isAnimationActive:!s},`${k.key}:planned`):null)]})})}),r&&(0,e.jsx)(oi,{ts:p,rows:E,variant:"inline"}),g&&(0,e.jsx)(Pt,{size:"small",pagination:!1,scroll:{x:!0,y:240},dataSource:S,columns:[{title:"Tarih",dataIndex:"date",key:"date"},{title:"Fiyat",dataIndex:"value",key:"value",align:"right"},{title:"Durum",dataIndex:"state",key:"state"}]})]})},{Text:ui}=X,Xc=({saleCoverage:t,beyondRetention:n,costStartsUnknown:r,costMigrationOnly:i})=>{const{token:a}=J.useToken(),s=[];return t&&(s.push(`SatıŠçizgileri PAZAROS'a kaydedilen fiyat deÄiÅimlerini gösterir. Otomatik kayıtlar ${t.retentionDays} gün sonra silinir; pazaryerindeki deÄiÅim zamanı farklı olabilir.`),t.oldestAvailableAt&&s.push(`Elimizdeki en eski satıŠkaydı: ${ze(t.oldestAvailableAt)}. Bundan öncesi için satıŠdeÄiÅimi bulunmuyor.`)),r&&s.push("Seçili aralıÄın baÅındaki alıŠfiyatı bilinmiyor; çizgi ilk bilinen kayıtta baÅlar."),i&&s.push("BaÅlangıç fiyatı aktarılmıÅtır; gözlemlenmiÅ bir fiyat deÄiÅimi deÄildir."),s.length===0?null:n&&t?.truncated?(0,e.jsx)(ce,{type:"info",showIcon:!0,title:"SatıŠverisi seçilen aralıÄın tamamını kapsamıyor",description:(0,e.jsx)(m,{vertical:!0,gap:4,children:s.map(l=>(0,e.jsx)(ui,{style:{fontSize:a.fontSizeSM},children:l},l))})}):(0,e.jsx)(m,{vertical:!0,gap:4,children:s.map(l=>(0,e.jsx)(ui,{type:"secondary",style:{fontSize:a.fontSizeSM},children:l},l))})},{Text:Jc}=X;function ed(t){const n=[];return t.examined!==void 0&&n.push(`${t.examined} sipariÅ incelendi`),t.updated!==void 0&&n.push(`${t.updated} güncellendi`),t.unchanged!==void 0&&n.push(`${t.unchanged} deÄiÅmedi`),t.failed&&n.push(`${t.failed} hata`),n.length>0?n.join(" · "):null}function td(t){if(!t)return null;const n=ed(t);switch(t.status){case"queued":return{tone:"info",title:"Fiyat kaydedildi. Yeniden hesaplama sırada.",detail:n,busy:!0};case"running":return{tone:"info",title:"Yeniden hesaplanıyor",detail:n,busy:!0};case"done":return t.failed&&t.failed>0?{tone:"warning",title:"Hatalarla tamamlandı",detail:n,busy:!1}:{tone:"success",title:"Tamamlandı",detail:n,busy:!1};case"failed":return{tone:"error",title:"Fiyat kaydedildi; yeniden hesaplama tamamlanamadı.",detail:n,busy:!1};case"superseded":return{tone:"info",title:"Daha yeni deÄiÅiklikle birleÅtirildi",detail:t.supersededBy?`Devralan iÅlem: ${t.supersededBy}`:n,busy:!1};default:return{tone:"warning",title:"Yeniden hesaplama durumu doÄrulanamadı",detail:n,busy:!1}}}var nd=({status:t,onRefresh:n,refreshing:r})=>{const{token:i}=J.useToken(),a=td(t);return a?(0,e.jsx)(ce,{type:a.tone,showIcon:!a.busy,icon:a.busy?(0,e.jsx)(gt,{size:16}):void 0,title:(0,e.jsxs)(m,{align:"center",justify:"space-between",gap:12,wrap:"wrap",children:[(0,e.jsx)("span",{"aria-live":"polite",children:a.title}),(0,e.jsx)(w,{type:"link",size:"small",loading:r,onClick:n,style:{padding:0},children:"Durumu yenile"})]}),description:a.detail?(0,e.jsx)(Jc,{type:"secondary",style:{fontSize:i.fontSizeSM},children:a.detail}):void 0}):null},{Text:rd}=X,qe=({label:t,children:n})=>(0,e.jsxs)(m,{justify:"space-between",gap:8,children:[(0,e.jsx)(rd,{type:"secondary",children:t}),(0,e.jsx)("span",{children:n})]}),{Text:rt}=X,mi={past:void 0,current:"success",planned:"processing"};function yi(t){return t.endKnown?t.endDay?ze(t.endDay):"Açık uçlu":(0,e.jsx)(ne,{title:"BitiÅ, komÅu kayıttan türetilir. KomÅu kayıt bu sayfada deÄil.",children:(0,e.jsx)(rt,{type:"secondary",children:"Bilinmiyor"})})}function pi(t){return t.isMigration?(0,e.jsx)(ne,{title:`Teknik tarih: ${at(t.entry.effectiveFrom)}. Ãnceki dönemlere uygulanan aktarılmıŠfiyattır; gözlemlenmiÅ bir fiyat deÄiÅimi deÄildir.`,children:(0,e.jsx)(rt,{children:"BaÅlangıç kaydı"})}):ze(t.startDay)}var id=({docs:t,loading:n,page:r,totalPages:i,total:a,onPageChange:s,newerNeighbourFrom:l,includesNewest:d,currentEntryId:g,pageSize:o,canWrite:p,onAdd:c,onEdit:u,onDelete:h,narrow:x})=>{const{token:b}=J.useToken(),E=(0,y.useMemo)(()=>Gi(t,{newerNeighbourFrom:l??null,includesNewest:d,isCurrent:j=>j.id===g}).reverse(),[t,l,d,g]),S=a>1,M=j=>(0,e.jsxs)(m,{align:"center",gap:4,justify:"flex-end",children:[(0,e.jsx)(ne,{title:p?void 0:kr,children:(0,e.jsx)(w,{type:"link",size:"small",disabled:!p,onClick:()=>u(j.entry),style:{padding:0,minHeight:44},children:"Düzenle"})}),(0,e.jsx)(Dn,{trigger:["click"],menu:{items:[{key:"delete",label:"Sil",danger:!0,disabled:!p||!S,onClick:()=>h(j.entry)}]},children:(0,e.jsx)(w,{type:"text",size:"small","aria-label":"DiÄer iÅlemler",style:{minHeight:44,minWidth:44},icon:(0,e.jsx)(_,{icon:zi,size:16})})})]});return!n&&t.length===0?(0,e.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:"AlıŠfiyatı geçmiÅi yok",children:p&&(0,e.jsx)(w,{"data-guide":"product-detail-cost-add",type:"primary",onClick:c,children:"İlk fiyatı ekle"})}):(0,e.jsxs)(m,{vertical:!0,gap:12,children:[(0,e.jsxs)(m,{align:"center",justify:"space-between",gap:12,wrap:"wrap",children:[(0,e.jsx)(rt,{strong:!0,children:"Tüm alıŠkayıtları"}),(0,e.jsx)(ne,{title:p?void 0:kr,children:(0,e.jsx)(w,{"data-guide":"product-detail-cost-add",type:"primary",disabled:!p,onClick:c,style:{minHeight:44},children:"+ AlıŠfiyatı ekle"})})]}),x?(0,e.jsx)(m,{vertical:!0,gap:16,children:E.map(j=>(0,e.jsxs)(m,{vertical:!0,gap:6,style:{borderBottom:`1px solid ${b.colorBorderSecondary}`,paddingBottom:12},children:[(0,e.jsxs)(m,{align:"center",justify:"space-between",gap:8,children:[(0,e.jsx)(rt,{strong:!0,style:{fontVariantNumeric:"tabular-nums"},children:he(j.entry.price,j.entry.currency)}),(0,e.jsx)(V,{color:mi[j.status],style:{margin:0},children:wr[j.status]})]}),(0,e.jsx)(qe,{label:"BaÅlangıç",children:pi(j)}),(0,e.jsx)(qe,{label:"BitiÅ",children:yi(j)}),(0,e.jsx)(qe,{label:"Kaynak",children:Er(j.entry.source)}),(0,e.jsx)(qe,{label:"OluÅturan",children:`${Sr(j.entry)} · ${at(j.entry.createdAt)}`}),M(j)]},j.entry.id))}):(0,e.jsx)(Pt,{size:"small",loading:n,rowKey:j=>j.entry.id,dataSource:E,pagination:!1,scroll:{x:!0},columns:[{title:"Fiyat",key:"price",align:"right",render:(j,k)=>(0,e.jsx)(rt,{style:{fontVariantNumeric:"tabular-nums"},children:he(k.entry.price,k.entry.currency)})},{title:"BaÅlangıç",key:"start",render:(j,k)=>pi(k)},{title:"BitiÅ",key:"end",render:(j,k)=>yi(k)},{title:"Durum",key:"status",render:(j,k)=>(0,e.jsx)(V,{color:mi[k.status],style:{margin:0},children:wr[k.status]})},{title:"Kaynak",key:"source",render:(j,k)=>Er(k.entry.source)},{title:"OluÅturan",key:"createdBy",render:(j,k)=>(0,e.jsxs)(m,{vertical:!0,children:[(0,e.jsx)(rt,{children:Sr(k.entry)}),(0,e.jsx)(rt,{type:"secondary",style:{fontSize:b.fontSizeSM},children:at(k.entry.createdAt)})]})},{title:"Son güncelleme",key:"updatedAt",render:(j,k)=>at(k.entry.updatedAt)},{title:"",key:"actions",align:"right",render:(j,k)=>M(k)}]}),i>1&&(0,e.jsx)(m,{justify:"flex-end",children:(0,e.jsx)(Ts,{current:r,total:a,pageSize:o,onChange:s,showSizeChanger:!1})})]})},{Text:ad}=X,hi={salePrice:"SatıŠfiyatı",price:"SatıŠfiyatı",listPrice:"Liste fiyatı"},gi={confirmed_push:"success",observed:"processing",local_change:void 0},sd=({docs:t,loading:n,hasMore:r,loadingMore:i,onLoadMore:a,marketplace:s,onMarketplaceChange:l,marketplaceOptions:d,listingId:g,onListingChange:o,listingOptions:p,narrow:c})=>{const{token:u}=J.useToken(),h=b=>(0,e.jsxs)(ad,{style:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:[b.oldPrice!=null?`${he(b.oldPrice,b.currency)} â `:"",he(b.price,b.currency)]}),x=(0,e.jsxs)(m,{gap:12,wrap:"wrap",children:[(0,e.jsx)(De,{allowClear:!0,style:{minWidth:180},placeholder:"Tüm pazaryerleri",value:s,onChange:b=>l(b??null),options:[...d],"aria-label":"Pazaryeri filtresi"}),p.length>1&&(0,e.jsx)(De,{allowClear:!0,style:{minWidth:200},placeholder:"Tüm ilanlar",value:g,onChange:b=>o(b??null),options:[...p],"aria-label":"İlan filtresi"})]});return!n&&t.length===0?(0,e.jsxs)(m,{vertical:!0,gap:12,children:[x,(0,e.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:"Bu aralıkta kayıtlı satıŠfiyatı deÄiÅimi yok"})]}):(0,e.jsxs)(m,{vertical:!0,gap:12,children:[x,c?(0,e.jsx)(m,{vertical:!0,gap:16,children:t.map(b=>(0,e.jsxs)(m,{vertical:!0,gap:6,style:{borderBottom:`1px solid ${u.colorBorderSecondary}`,paddingBottom:12},children:[(0,e.jsxs)(m,{align:"center",justify:"space-between",gap:8,children:[(0,e.jsx)(Qt,{marketplace:b.marketplace,height:16}),h(b)]}),(0,e.jsx)(qe,{label:"İlan",children:b.listingLabel}),(0,e.jsx)(qe,{label:"Alan",children:hi[b.field]}),(0,e.jsx)(qe,{label:"Zaman",children:at(b.recordedAt)}),(0,e.jsx)(qe,{label:"DoÄrulama",children:(0,e.jsx)(V,{color:gi[b.evidenceKind],style:{margin:0},children:Tr(b.evidenceKind)})})]},b.eventId))}):(0,e.jsx)(Pt,{size:"small",loading:n,rowKey:"eventId",dataSource:[...t],pagination:!1,scroll:{x:!0},columns:[{title:"Pazaryeri",key:"marketplace",render:(b,E)=>(0,e.jsx)(Qt,{marketplace:E.marketplace,height:16})},{title:"İlan / SKU",dataIndex:"listingLabel",key:"listingLabel"},{title:"Alan",key:"field",render:(b,E)=>hi[E.field]},{title:"Fiyat",key:"price",align:"right",render:(b,E)=>h(E)},{title:"Zaman",key:"recordedAt",render:(b,E)=>at(E.recordedAt)},{title:"Kaynak",dataIndex:"source",key:"source"},{title:"DoÄrulama",key:"evidence",render:(b,E)=>(0,e.jsx)(V,{color:gi[E.evidenceKind],style:{margin:0},children:Tr(E.evidenceKind)})},{title:"Kim",key:"actor",render:(b,E)=>E.actor||"Kullanıcı bilgisi yok"}]}),r&&(0,e.jsx)(m,{justify:"center",children:(0,e.jsx)(w,{loading:i,onClick:a,style:{minHeight:44},children:"Daha fazla kayıt göster"})})]})},{Text:St,Paragraph:ld}=X,od={create:"AlıŠfiyatı ekle",update:"GeçmiÅ fiyatı deÄiÅtir",delete:"AlıŠfiyatı kaydını sil"},fi=({open:t,operation:n,draft:r,preview:i,loading:a,error:s,stale:l,confirming:d,isFirstEntry:g,onConfirm:o,onRetry:p,onCancel:c})=>{const{token:u}=J.useToken(),h=i?.sameDayConflict??null,x=i?.affectedOrders??null,b=i!==null&&x===null,E=i!==null&&!a&&!l&&!b&&h===null,S=n==="delete"?"Sil ve yeniden hesapla":i&&i.recalculationRequired&&(x??0)>0?"Kaydet ve yeniden hesapla":"Kaydet";return(0,e.jsxs)(zt,{open:t,title:od[n],onCancel:c,maskClosable:!1,focusTriggerAfterClose:!0,destroyOnClose:!0,footer:(0,e.jsxs)(m,{justify:"flex-end",gap:8,children:[(0,e.jsx)(w,{onClick:c,style:{minHeight:44},children:"Geri dön"}),(s!==null||l||b)&&(0,e.jsx)(w,{onClick:p,loading:a,style:{minHeight:44},children:"Yeniden incele"}),(0,e.jsx)(w,{"data-guide":"product-detail-cost-confirm",type:"primary",danger:n==="delete",disabled:!E,loading:d,onClick:o,style:{minHeight:44},children:S})]}),children:[a&&(0,e.jsx)(m,{justify:"center",align:"center",style:{minHeight:160},children:(0,e.jsx)(gt,{})}),!a&&s!==null&&(0,e.jsx)(ce,{type:"error",showIcon:!0,title:"Etki önizlemesi alınamadı",description:`${s} TaslaÄınız korundu; yeniden inceleyebilirsiniz.`}),!a&&s===null&&i&&(0,e.jsxs)(m,{vertical:!0,gap:16,children:[h&&(0,e.jsx)(ce,{type:"warning",showIcon:!0,title:`Bu tarihte ${he(h.price,h.currency)}
29 kayıtlı.`,description:"Mevcut kaydı düzenleyin. Aynı güne ikinci bir kayıt sessizce üzerine yazılmaz."}),l&&(0,e.jsx)(ce,{type:"warning",showIcon:!0,title:"Ãnizleme güncel deÄil",description:"Fiyat veya tarih deÄiÅti; aÅaÄıdaki sayı önceki taslaÄa ait. Yeniden inceleyin."}),(0,e.jsx)(Ci,{column:1,size:"small",items:[...n!=="delete"&&r?[{key:"price",label:"AlıŠfiyatı",children:(0,e.jsxs)(St,{strong:!0,style:{fontVariantNumeric:"tabular-nums"},children:[i.before?.price!=null?`${he(i.before.price,i.before.currency)} â `:"",he(r.price,r.currency)]})},{key:"from",label:"BaÅlangıç",children:ze(r.effectiveFrom)}]:[],{key:"range",label:"Etkilenen dönem",children:`${ze(i.affectedRange.from)} â ${i.affectedRange.toExclusive?ze(i.affectedRange.toExclusive):"Açık uçlu"}`}]}),b?(0,e.jsx)(ce,{type:"warning",showIcon:!0,title:"Etkilenen sipariÅ sayısı alınamadı",description:"Kaydetme adımı bu sayı olmadan devam etmez. Yeniden inceleyin."}):x===0?(0,e.jsx)(St,{children:"Mevcut sipariÅlerden etkilenen yok."}):(0,e.jsxs)(m,{vertical:!0,gap:4,children:[(0,e.jsx)(St,{strong:!0,children:`${x} sipariÅ yeniden hesaplanacak.`}),(0,e.jsx)(ld,{type:"secondary",style:{margin:0,fontSize:u.fontSizeSM},children:"KapanmıŠdönemler dahil bu sipariÅlerin maliyet ve kâr sonuçları deÄiÅebilir."})]}),typeof i.maxAffectedSnapshotDays=="number"&&i.maxAffectedSnapshotDays>0&&(0,e.jsx)(St,{strong:!0,children:`En fazla ${i.maxAffectedSnapshotDays} günün panosu yeniden hesaplanacak.`}),n==="delete"&&(0,e.jsx)(ce,{type:"info",showIcon:!0,title:"Silinen dönem hangi fiyatla hesaplanacak?",description:g?"Bu ilk kayıt. SilindiÄinde sonraki ilk kayıt, daha eski sipariÅlere de uygulanabilir.":i.after?.price!=null?`Dönem, ${he(i.after.price,i.after.currency)} olan bir önceki kayıtla hesaplanacak.`:"Dönem, komÅu kayıtlardan çözülecek."}),(0,e.jsx)(St,{type:"secondary",style:{fontSize:u.fontSizeSM},children:"Sayı, önizleme anındaki sipariÅlere göredir."})]})]})},{Text:cd}=X,zn=200,dd=({open:t,productId:n,operation:r,entry:i,allEntries:a,isFirstEntry:s=!1,onClose:l,onSaved:d})=>{const{token:g}=J.useToken(),{message:o}=st.useApp(),[p]=W.useForm(),[c,u]=(0,y.useState)(!1),[h,x]=(0,y.useState)(null),[b,E]=(0,y.useState)(null),S=Hc(),M=Wc(n),j=W.useWatch([],p);(0,y.useEffect)(()=>{if(t){if(S.reset(),u(!1),x(null),E(null),r==="delete"){H(null);return}p.setFieldsValue({price:i?.price??0,currency:i?.currency??"TRY",effectiveFrom:i?(0,Et.default)(i.effectiveFrom):(0,Et.default)(),note:i?.note??void 0})}},[t,i,r]);const k=(0,y.useMemo)(()=>Al(r==="update"&&i?a.filter(v=>v.effectiveFrom!==i.effectiveFrom):a),[a,r,i]),z=j?.effectiveFrom?.format("YYYY-MM-DD")??Xn(),C=fl(z)&&!k.allowed,L=r==="update"&&i!=null&&j!==void 0&&j.price===i.price&&j.currency===i.currency&&j.effectiveFrom?.format("YYYY-MM-DD")===(0,Et.default)(i.effectiveFrom).format("YYYY-MM-DD"),R=(v,A,ye)=>[r,i?.id??"",v,A,ye].join("|"),N=j?.price!==void 0&&j.currency&&j.effectiveFrom?R(j.price,j.currency,j.effectiveFrom.format(Cr)):null,de=b!==null&&N!==null&&N!==b,H=async v=>{x(v),E(null);try{await S.mutateAsync({subjectType:"productPurchase",subjectId:n,operation:r,...i?{entryId:i.id}:{},...v?{draft:v}:{}}),E(v?R(v.price,v.currency,v.effectiveFrom):null)}catch{}},q=async()=>{let v;try{v=await p.validateFields()}catch{return null}return{price:v.price,currency:v.currency,effectiveFrom:v.effectiveFrom.format(Cr),...v.note?{note:v.note}:{}}},Y=async()=>{const v=await q();v&&await H(v)},I=async()=>{const v=await q();if(v){if(L){try{await M.mutateAsync({operation:"update",entryId:i?.id,draft:v})}catch(A){o.error(A instanceof Error?A.message:"Not kaydedilemedi");return}o.success("Not güncellendi"),d();return}u(!0),await H(v)}},P=async()=>{if(!(!h&&r!=="delete"))try{const v=await M.mutateAsync({operation:r,...i?{entryId:i.id}:{},...h?{draft:h}:{}}),A=bl(v.recalculation);A.tone==="warning"?o.warning(A.text):o.success(A.text),u(!1),d()}catch(v){o.error(v instanceof Error?v.message:"Fiyat kaydedilemedi")}};return r==="delete"?(0,e.jsx)(fi,{open:t,operation:"delete",draft:null,preview:S.data??null,loading:S.isPending,error:S.error?S.error.message:null,stale:!1,confirming:M.isPending,isFirstEntry:s,onConfirm:()=>{P()},onRetry:()=>{H(null)},onCancel:l}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(qn,{"data-guide":"product-detail-cost-drawer",open:t,onClose:l,title:r==="create"?"AlıŠfiyatı ekle":"AlıŠfiyatını düzenle",width:480,destroyOnClose:!0,footer:(0,e.jsxs)(m,{justify:"flex-end",gap:8,children:[(0,e.jsx)(w,{onClick:l,style:{minHeight:44},children:"Vazgeç"}),(0,e.jsx)(w,{"data-guide":"product-detail-cost-inspect",type:"primary",disabled:C,loading:S.isPending||M.isPending,onClick:()=>{I()},style:{minHeight:44},children:L?"Notu kaydet":"Etkiyi incele"})]}),children:(0,e.jsxs)(W,{form:p,layout:"vertical",requiredMark:!1,children:[(0,e.jsx)(W.Item,{"data-guide":"product-detail-cost-price",name:"price",label:"Fiyat",rules:[{required:!0,message:"Fiyat zorunlu"},{type:"number",min:0,message:"Fiyat sıfır veya pozitif olmalı"}],children:(0,e.jsx)(Ee,{style:{width:"100%"},decimalSeparator:",",precision:2,min:0})}),(0,e.jsx)(W.Item,{name:"currency",label:"Para birimi",rules:[{required:!0}],children:(0,e.jsx)(De,{options:yl.map(v=>({value:v,label:v}))})}),(0,e.jsx)(W.Item,{name:"effectiveFrom",label:"Geçerlilik baÅlangıcı",rules:[{required:!0,message:"BaÅlangıç tarihi zorunlu"}],children:(0,e.jsx)(Ss,{style:{width:"100%"},format:"DD.MM.YYYY",allowClear:!1})}),(0,e.jsx)(cd,{type:"secondary",style:{fontSize:g.fontSizeSM},children:"Bu fiyat seçilen gün 00:00'dan itibaren geçerlidir. Saat dilimi: İstanbul."}),(0,e.jsx)(W.Item,{name:"note",label:"Not",style:{marginTop:16},rules:[{max:zn,message:`En fazla ${zn} karakter`}],children:(0,e.jsx)(Le.TextArea,{rows:3,maxLength:zn,showCount:!0})}),C&&(0,e.jsx)(ce,{type:"warning",showIcon:!0,title:"İleri tarihli kayıt eklenemez",description:k.reason})]})}),(0,e.jsx)(fi,{open:c,operation:r,draft:h,preview:S.data??null,loading:S.isPending,error:S.error?S.error.message:null,stale:de,confirming:M.isPending,isFirstEntry:s,onConfirm:()=>{P()},onRetry:()=>{Y()},onCancel:()=>u(!1)})]})},{Text:An,Title:ud}=X,Ln=20,md=t=>t==="add",yd=({productId:t,canWrite:n,beforeMutate:r})=>{const{token:i}
29=J.useToken(),a=rn.useBreakpoint(),s=Object.keys(a).length>0&&!a.md,l=Ys()??!1,[d,g]=(0,y.useState)("90d"),[o,p]=(0,y.useState)(!1),[c,u]=(0,y.useState)(null),[h,x]=(0,y.useState)(1),[b,E]=(0,y.useState)(null),[S,M]=(0,y.useState)(null),[j,k]=(0,y.useState)(null),z=Ar("priceAction",{validate:md}),C=Ar("priceEntry"),[L]=Yn("priceSeries",Ei.withDefault("")),R=Nc(t,{range:d,includePlanned:o}),N=si(t,{page:h,limit:Ln}),de=si(t,{page:h-1,limit:Ln,enabled:h>1}),H=Yc(t,{range:d,marketplace:b,listingId:S}),q=R.data===void 0?!1:R.data.entries.length>0||R.data.boundaryBefore!=null,Y=Kc(t,q),I=N.data?.docs??[],P=de.data?.docs??[],v=h>1?P[P.length-1]?.effectiveFrom??null:null,A=(0,y.useMemo)(()=>H.data?.pages.flatMap(D=>D.docs)??[],[H.data]),ye=H.data?.pages[0]?.coverage??null,K=(0,y.useMemo)(()=>R.data?Ll(R.data,{from:qt(d).from,includePlanned:o}):[],[R.data,d,o]),ee=(0,y.useMemo)(()=>Ir(A,{marketplaceLabel:Ve}),[A]),pe=(0,y.useMemo)(()=>kl(A,{field:"listPrice",marketplaceLabel:Ve}),[A]),re=(0,y.useMemo)(()=>[...K,...ee,...pe],[K,ee,pe]),xe=(0,y.useMemo)(()=>{const D=new Map;for(const U of ee)U.marketplace&&D.set(U.marketplace,(D.get(U.marketplace)??0)+1);return[...K.map(U=>U.key),...ee.filter(U=>U.marketplace&&D.get(U.marketplace)===1).map(U=>U.key)]},[K,ee]),ge=(0,y.useMemo)(()=>{if(!L)return[];const D=re.filter(U=>U.key===L);return D.length>0?D.map(U=>U.key):L==="cost"?re.filter(U=>U.kind==="cost").map(U=>U.key):re.filter(U=>U.kind==="sale"&&U.field!=="listPrice"&&U.marketplace===L).map(U=>U.key)},[L,re]),ie=(0,y.useMemo)(()=>c!==null?c:ge.length>0?[...new Set([...xe,...ge])]:xe,[c,xe,ge]),ue=(0,y.useMemo)(()=>pe.some(D=>ie.includes(D.key))?Ir(A,{field:"listPrice",marketplaceLabel:Ve}):[],[pe,ie,A]),we=(0,y.useMemo)(()=>[...K,...ee,...ue].filter(D=>ie.includes(D.key)),[K,ee,ue,ie]),Z=(0,y.useMemo)(()=>Sl(we),[we]),me=(0,y.useCallback)(D=>D.kind==="cost"?i.colorPrimary:D.marketplace?Ri(D.marketplace):i.colorTextSecondary,[i.colorPrimary,i.colorTextSecondary]),ae=(0,y.useMemo)(()=>{if(!R.data)return null;const D=[...R.data.boundaryBefore?[R.data.boundaryBefore]:[],...R.data.entries,...R.data.planned];if(D.length===0)return null;const U=Gi(D);return{current:U.find(O=>O.status==="current"),nextPlanned:U.find(O=>O.status==="planned")}},[R.data]),T=ae?.current?.entry.entryId??null,He=C.isOpen?I.find(D=>D.id===C.value)??null:null;(0,y.useEffect)(()=>{C.isOpen&&(N.isLoading||N.isFetching||He||C.close())},[C,N.isLoading,N.isFetching,He]);const ke=j?{operation:"delete",entry:j}:z.isOpen?{operation:"create",entry:null}:He?{operation:"update",entry:He}:null,be=(0,y.useCallback)(D=>{D==="delete"?(j&&C.value===j.id&&C.close(),k(null)):D==="create"?z.close():C.close()},[z,C,j]),We=async D=>{r&&!await r()||D()},Je=Xn(),Ce=(0,y.useMemo)(()=>Qn(Je).startOf("day").valueOf(),[Je]),et=R.data?.planned.length??0,ve=qt(d),Ge=o?R.data?.planned[et-1]?.effectiveFrom:void 0,lt=`Gösterilen aralık: ${ve.from?ze(ve.from):"tüm kayıtlar"} â ${ze(Ge??ve.to)}`,ot=(0,y.useMemo)(()=>ee.filter(D=>!b||D.marketplace===b).map(D=>({value:D.listingId??"",label:D.label})),[ee,b]),tt=(0,y.useMemo)(()=>{const D=new Set,U=[];for(const O of ee)!O.marketplace||D.has(O.marketplace)||(D.add(O.marketplace),U.push({value:O.marketplace,label:Ve(O.marketplace)}));return U},[ee]);return R.isError&&!R.data?(0,e.jsx)(ce,{type:"error",showIcon:!0,title:"Fiyat geçmiÅi yüklenemedi",description:(0,e.jsx)(w,{onClick:()=>{R.refetch()},style:{minHeight:44,padding:0},type:"link",children:"Yeniden dene"})}):R.isLoading&&!R.data?(0,e.jsx)(Re,{active:!0,paragraph:{rows:8},style:{minHeight:320}}):(0,e.jsxs)(m,{vertical:!0,gap:20,children:[ae?.current&&(0,e.jsxs)(m,{vertical:!0,gap:2,children:[(0,e.jsx)(An,{type:"secondary",children:"Bugün geçerli alıÅ"}),(0,e.jsxs)(ud,{level:4,style:{margin:0},children:[he(ae.current.entry.price,ae.current.entry.currency),(0,e.jsx)(An,{type:"secondary",style:{fontSize:i.fontSize,fontWeight:400},children:ae.current.isMigration?" · baÅlangıç kaydından beri":` · ${ze(ae.current.startDay)}'dan beri`})]}),ae.nextPlanned&&(0,e.jsx)(An,{type:"secondary",children:`Sonraki fiyat: ${he(ae.nextPlanned.entry.price,ae.nextPlanned.entry.currency)} · ${ze(ae.nextPlanned.startDay)}`})]}),(0,e.jsx)(Uc,{range:d,onRangeChange:g,plannedCount:et,showPlanned:o,onShowPlannedChange:p,rangeLabel:lt,busy:R.isFetching||H.isFetching}),(0,e.jsx)(qc,{series:re,selected:ie,onChange:u,narrow:s,colorFor:me}),H.isError&&(0,e.jsx)(ce,{type:"warning",showIcon:!0,title:"SatıŠdeÄiÅimleri yüklenemedi",description:(0,e.jsx)(w,{type:"link",style:{padding:0},onClick:()=>{H.refetch()},children:"Yeniden dene"})}),re.length===0?(0,e.jsx)(ce,{type:"info",showIcon:!0,title:"Bu aralıkta gösterilecek fiyat kaydı yok."}):we.length===0?(0,e.jsx)(ce,{type:"info",showIcon:!0,title:"GrafiÄi görmek için en az bir seri seçin."}):(0,e.jsx)(m,{vertical:!0,gap:16,children:Z.map(D=>(0,e.jsx)(Qc,{series:D.series,currency:D.currency,narrow:s,todayTs:Ce,colorFor:me,reducedMotion:l},D.currency))}),(0,e.jsx)(Xc,{saleCoverage:ye,beyondRetention:vl.includes(d),c
29ostStartsUnknown:R.data?.coverage.hasEarlier===!1&&K.length>0,costMigrationOnly:(R.data?.entries.length??0)===0&&R.data?.boundaryBefore?.source==="migration"}),q&&(0,e.jsx)(nd,{status:Y.data,onRefresh:()=>{Y.refetch()},refreshing:Y.isFetching}),(0,e.jsx)(fs,{items:[{key:"cost",label:"AlıŠkayıtları",children:(0,e.jsx)(id,{docs:I,loading:N.isLoading,page:h,totalPages:N.data?.totalPages??1,total:N.data?.totalDocs??I.length,pageSize:Ln,onPageChange:x,newerNeighbourFrom:v,includesNewest:h===1,currentEntryId:T,canWrite:n,narrow:s,onAdd:()=>{We(()=>z.open("add"))},onEdit:D=>{We(()=>C.open(D.id))},onDelete:D=>{We(()=>k(D))}})},{key:"sale",label:"SatıŠdeÄiÅimleri",children:(0,e.jsx)(sd,{docs:A,loading:H.isLoading,hasMore:!!H.hasNextPage,loadingMore:H.isFetchingNextPage,onLoadMore:()=>{H.fetchNextPage()},marketplace:b,onMarketplaceChange:D=>{E(D),M(null)},marketplaceOptions:tt,listingId:S,onListingChange:M,listingOptions:ot,narrow:s})}]}),ke&&(0,e.jsx)(dd,{open:!0,productId:t,operation:ke.operation,entry:ke.entry,allEntries:I,isFirstEntry:ke.entry!==null&&I[I.length-1]?.id===ke.entry.id&&(N.data?.totalPages??1)===h,onClose:()=>be(ke.operation),onSaved:()=>{be(ke.operation),u(null)}})]})},{Text:en}=X,pd=/^[0-9A-Za-z-]{4,32}$/,hd="Yalnız maÄaza yöneticisi deÄiÅtirebilir",Ea={icon:(0,e.jsx)(_,{icon:yt,size:12}),tooltips:["Kopyala","Kopyalandı"]},Rn=({value:t,style:n,copy:r=!0})=>(0,e.jsx)(en,{copyable:r?{...Ea,text:t}:!1,ellipsis:{tooltip:t},style:{...n,minWidth:0,maxWidth:"100%"},children:t}),xi=({value:t})=>(0,e.jsx)(en,{copyable:{...Ea,text:t}}),gd=({product:t,canEditDesiPreference:n,buyboxMarketplaces:r,tagsSlot:i})=>{const{token:a}=J.useToken(),s={fontFamily:a.fontFamilyCode},l=t.desiPreference??"marketplaceFirst",d=r.length>0?(0,e.jsx)(m,{gap:6,wrap:"wrap",children:r.map(u=>{const h=Xe[u];return h?(0,e.jsx)(V,{color:h.color,icon:(0,e.jsx)(_,{icon:Li,size:12}),style:{margin:0},children:h.name},u):(0,e.jsx)(V,{style:{margin:0},children:u},u)})}):(0,e.jsx)(en,{type:"secondary",children:"Takip yok"}),g=(0,e.jsx)(Rn,{value:t.id,style:s}),o={xs:24,sm:12},p=(0,e.jsx)(en,{type:"secondary",children:"â"}),c=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(F,{...o,children:(0,e.jsx)(Hn,{label:"Buybox takibi",children:d})}),(0,e.jsx)(F,{...o,children:(0,e.jsx)(Hn,{label:"Ãrün ID",children:g})})]});return(0,e.jsxs)(_e,{gutter:[24,0],children:[(0,e.jsx)(F,{...o,children:(0,e.jsx)(Ke,{editKey:"canonicalBarcode",label:"Barkod",dataField:"canonicalBarcode",action:t.canonicalBarcode?(0,e.jsx)(xi,{value:t.canonicalBarcode}):void 0,edit:(0,e.jsx)(W.Item,{name:"canonicalBarcode",label:"Barkod",rules:[{pattern:pd,warningOnly:!0,message:"Barkod 4â32 harf, rakam veya tire olmalı"}],children:(0,e.jsx)(Le,{style:s,maxLength:64,autoFocus:!0})}),children:t.canonicalBarcode?(0,e.jsx)(Rn,{value:t.canonicalBarcode,style:s,copy:!1}):p})}),(0,e.jsx)(F,{...o,children:(0,e.jsx)(Ke,{editKey:"canonicalStockCode",label:"Stok kodu (SKU)",dataField:"canonicalStockCode",action:t.canonicalStockCode?(0,e.jsx)(xi,{value:t.canonicalStockCode}):void 0,edit:(0,e.jsx)(W.Item,{name:"canonicalStockCode",label:"Stok kodu (SKU)",extra:"BoÅ bırakılırsa PZROS-⦠ile otomatik üretilir",children:(0,e.jsx)(Le,{style:s,maxLength:64,autoFocus:!0})}),children:t.canonicalStockCode?(0,e.jsx)(Rn,{value:t.canonicalStockCode,style:s,copy:!1}):p})}),(0,e.jsx)(F,{...o,children:(0,e.jsx)(Ke,{editKey:"desi",label:"Desi",dataField:"desi",edit:(0,e.jsx)(W.Item,{name:"desi",label:"Desi",rules:[{type:"number",min:0,message:"Desi negatif olamaz"}],children:(0,e.jsx)(Ee,{min:0,step:.001,autoFocus:!0,style:{width:"100%"}})}),children:t.desi!=null?Lr(t.desi):p})}),(0,e.jsx)(F,{...o,children:(0,e.jsx)(Ke,{editKey:"desiPreference",label:"Desi tercihi",dataField:"desiPreference",readOnly:!n,extra:n?void 0:hd,edit:(0,e.jsx)(W.Item,{name:"desiPreference",label:"Desi tercihi",children:(0,e.jsx)(De,{options:xa,autoFocus:!0,style:{width:"100%"}})}),children:(0,e.jsx)(V,{color:l==="manualAlways"?"blue":"default",style:{margin:0},children:rc[l]})})}),(0,e.jsx)(F,{...o,children:(0,e.jsx)(Ke,{editKey:"maxDesi",label:"Maks. desi",dataField:"maxDesi",edit:(0,e.jsx)(W.Item,{name:"maxDesi",label:"Maks. desi",rules:[{type:"number",min:0,message:"Maks. desi negatif olamaz"}
29],children:(0,e.jsx)(Ee,{min:0,step:.001,autoFocus:!0,style:{width:"100%"}})}),children:t.maxDesi!=null?Lr(t.maxDesi):p})}),c,i&&(0,e.jsx)(F,{...o,children:(0,e.jsxs)("div",{style:{marginBottom:20,minWidth:0},children:[(0,e.jsx)(va,{children:"Etiketler"}),i]})})]})},rr=[{id:"barcode",label:"Barkod"},{id:"stockCode",label:"Stok kodu"},{id:"sale",label:"SatıŠfiyatı"},{id:"list",label:"Liste fiyatı"},{id:"shippingCost",label:"Kargo"},{id:"qty",label:"Stok"}],fd=(t,n,r)=>{const i=on(t)[r];return i?[t,n,i]:null},Ia=[{name:"title",label:"Ãrün adı",section:"ozet"},{name:"stock",label:"Ana stok",section:"bilgiler",group:"stok-fiyat"},{name:"purchasePrice",label:"AlıŠfiyatı",section:"bilgiler",group:"stok-fiyat"},{name:"purchaseCurrency",label:"AlıŠpara birimi",section:"bilgiler",group:"stok-fiyat"},{name:"shippingCost",label:"Kargo ücreti",section:"bilgiler",group:"stok-fiyat"},{name:"additionalExpenses",label:"Ek giderler",section:"bilgiler",group:"stok-fiyat"},{name:"canonicalBarcode",label:"Barkod",section:"bilgiler",group:"kimlik"},{name:"canonicalStockCode",label:"Stok kodu (SKU)",section:"bilgiler",group:"kimlik"},{name:"desi",label:"Desi",section:"bilgiler",group:"kimlik"},{name:"desiPreference",label:"Desi tercihi",section:"bilgiler",group:"kimlik"},{name:"maxDesi",label:"Maks. desi",section:"bilgiler",group:"kimlik"}],yn=Object.fromEntries(Ia.map(t=>[t.name,t])),ki=t=>typeof t=="string"&&t in yn;function tn(t){if(t!=null){if(typeof t=="string")return t.trim()===""?void 0:t;if(Array.isArray(t))return t.map(tn);if(typeof t=="object"){const n={};for(const[r,i]of Object.entries(t)){const a=tn(i);a!==void 0&&(n[r]=a)}return n}return t}}var Ca=(t,n)=>!ul(tn(t),tn(n));function xd(t,n){return!t||!n?[]:Ia.filter(r=>Ca(t[r.name],n[r.name])).map(r=>r.name)}function kd(t,n){if(!t||!n)return[];const r=[];for(const i of it){const a=t[i]??[],s=n[i]??[];if(s.length===0&&a.length===0)continue;const l=on(i),d=Math.max(a.length,s.length),g=d>1;for(let o=0;o<d;o+=1)for(const p of rr){const c=l[p.id];if(!c||!Ca(a[o]?.[c],s[o]?.[c]))continue;const u=Xe[i].name;r.push({marketplace:i,index:o,field:p.id,label:`${u}${g?` (${o+1})`:""}: ${p.label}`})}}return r}function bd(t,n=[]){const r={};for(const i of t){const a=yn[i].section;r[a]=(r[a]??0)+1}return n.length>0&&(r.pazaryerleri=(r.pazaryerleri??0)+n.length),r}var jd=(t,n,r)=>`${t}.${n}.${r}`,bi=(t,n)=>`${t}.${n}`,wa=new Set(it);function vd(t){const n=Array.isArray(t)?t:typeof t=="string"?t.split("."):[];if(n.length===0)return null;if(n.length===1&&ki(n[0]))return n[0];if(n.length===3&&typeof n[0]=="string"&&wa.has(n[0])){const r=n[0],i=Number(n[1]),a=n[2];return!Number.isInteger(i)||i<0||typeof a!="string"||!Object.values(on(r)).filter(Boolean).includes(a)?null:[r,i,a]}return ki(n[0])?n[0]:null}function Sd(t){if(!Array.isArray(t))return yn[t].label;const[n,r,i]=t;if(typeof n!="string"||!wa.has(n))return t.join(".");const a=on(n),s=rr.find(l=>a[l.id]===i);return`${Xe[n].name} ${Number(r)+1}. ilan: ${s?.label??String(i)}`}function Td(t){const n=new Map,r=(i,a)=>{if(!i||typeof i!="object"||a>12)return;if(Array.isArray(i)){for(const d of i)r(d,a+1);return}const s=i,l=vd(s.field??s.path);if(l&&typeof s.message=="string"){const d=Array.isArray(l)?l.join("."):l,g=n.get(d)??{name:l,errors:[]};g.errors.push(s.message),n.set(d,g)}for(const d of["errors","data","response","cause","validations"])d in s&&r(s[d],a+1)};return r(t,0),[...n.values()]}var Ed="KaydedilmemiÅ deÄiÅiklikler var";function Id(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return null;const n=t.target;if(!(n instanceof Element))return null;const r=n.closest("a[href]");if(!(r instanceof HTMLAnchorElement)||r.target&&r.target!=="_self"||r.hasAttribute("download"))return null;const i=r.getAttribute("href")??"";return!i.startsWith("/")||i.startsWith("//")?null:i}function Cd(t,n={}){const{modal:r}=st.useApp(),i=nn(),{registerGuard:a}=Us(),s=Zt(n),l=Zt(t),d=(0,y.useRef)(null),g=(0,y.useCallback)(()=>{if(!l.current)return Promise.resolve(!0);if(d.current)return d.current;const o=new Promise(p=>{r.confirm({title:Ed,content:(s.current.description?`${s.current.description}. `:"")+"Sayfadan ayrılırsanız deÄiÅiklikler kaybolur.",okText:"Ayrıl",okButtonProps:{danger:!0},cancelText:"Sayfada kal",onOk:()=>p(!0),onCancel:()=>p(!1)})}).finally(()=>{d.current=null});return d.current=o,o},[l,r,s]);return(0,y.useEffect)(()=>
29{if(!t)return;const o=p=>{p.preventDefault(),p.returnValue=""};return window.addEventListener("beforeunload",o),()=>window.removeEventListener("beforeunload",o)},[t]),(0,y.useEffect)(()=>{if(!t)return;const o=p=>{const c=Id(p);c&&(p.preventDefault(),p.stopPropagation(),g().then(u=>{u&&i(c)}))};return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[t,g,i]),(0,y.useEffect)(()=>{if(t)return a(g)},[t,g,a]),g}function wd(){const t=(0,y.useRef)(null),[n,r]=(0,y.useState)(!1);return{isOpen:n,request:(0,y.useCallback)(()=>{if(t.current)return t.current.promise;let i;const a=new Promise(s=>{i=s});return t.current={promise:a,resolve:i},r(!0),a},[]),settle:(0,y.useCallback)(i=>{const a=t.current;t.current=null,r(!1),a?.resolve(i)},[])}}var{Text:Pd}=X,Pa=124;var zd={components:{Anchor:{linkPaddingInlineStart:28,linkPaddingBlock:10}}};function za(t){return t==="horizontal"?180:Pa}var Ad=({sections:t,direction:n,counts:r,changedCounts:i})=>{const{token:a}=J.useToken(),s=n==="horizontal",l=za(n),d=(0,y.useMemo)(()=>t.map(o=>{const p=r?.[o.id],c=i?.[o.id]??0;return{key:o.id,href:`#${dn(o.id)}`,title:(0,e.jsxs)(m,{align:"center",gap:8,style:{minWidth:0},children:[(0,e.jsx)(_,{icon:o.icon,size:14}),(0,e.jsx)("span",{style:{whiteSpace:"nowrap"},children:o.label}),p!=null&&(0,e.jsx)(Pd,{type:"secondary",style:{fontSize:a.fontSizeSM},children:p}),c>0&&(0,e.jsx)(V,{color:"warning",style:{margin:0,lineHeight:"18px"},"aria-label":`${c} alan deÄiÅti`,"data-testid":`nav-changed-${o.id}`,children:c})]})}}),[t,r,i,a.fontSizeSM]),g=s?{position:"sticky",top:108,zIndex:10,minHeight:56,display:"flex",alignItems:"center",overflowX:"auto",scrollbarWidth:"thin",paddingInline:4,background:a.colorBgLayout,borderBottom:`1px solid ${a.colorBorderSecondary}`,marginTop:8,marginBottom:16}:{position:"sticky",top:Pa,width:200,flexShrink:0,alignSelf:"flex-start",display:"flex",flexDirection:"column",gap:12};return(0,e.jsx)("nav",{"aria-label":"Sayfa bölümleri","data-guide":"pdetail-nav",style:g,children:(0,e.jsx)(Ii,{theme:s?zd:void 0,children:(0,e.jsx)(ks,{affix:!1,direction:n,items:d,getContainer:()=>ha()??window,targetOffset:l,onClick:o=>o.preventDefault()})})})};function Ld(t,n){const[r]=Yn("tab"),i=typeof window<"u"?window.location.hash:"",a=Kn(r,i),s=Oo(r,i),l=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!t||!a||!s)return;const d=`${r??""}|${i}`;if(l.current===d)return;const g=requestAnimationFrame(()=>{const o={behavior:"auto",offset:n};(ga(s,o)||Hr(a,o))&&(l.current=d)});return()=>cancelAnimationFrame(g)},[t,a,s,r,i,n]),{initialSection:a,jumpTo:(0,y.useCallback)(d=>Hr(d,{offset:n}),[n])}}var Rd="Bu ürün için Pazaros üzerinden bir Hepsiburada yayın kaydı bulunmuyor. Ãrün Hepsiburada'ya buradan hiç gönderilmemiÅ olabilir.",Mn=t=>typeof t=="number"?t:0;function Md(t){if(!t)return{line:Rd};const n=vr(t.submittedAt),r=Mn(t.summary?.created),i=Mn(t.summary?.matched),a=Mn(t.summary?.errored);let s;switch(t.state){case"pending":case"processing":s=`${n} tarihinde Hepsiburada'ya gönderildi. Hepsiburada gönderimi hâlâ iÅliyor, sonuç henüz belli deÄil.`;break;case"completed":s=`${n} tarihinde gönderildi, Hepsiburada iÅlemi tamamladı (${r} ürün oluÅturuldu, ${i} ürün eÅleÅti).`;break;case"partial":s=`${n} tarihinde gönderildi, Hepsiburada gönderimi kısmen kabul etti (${r} ürün oluÅturuldu, ${a} ürün hatalı).`;break;case"failed":s=`${n} tarihinde gönderildi, Hepsiburada gönderimi reddetti (${a} ürün hatalı).`;break;case"abandoned":s=`${n} tarihinde gönderildi, ancak Hepsiburada gönderimin sonucunu hiç bildirmedi; takip durduruldu. Ãrünün Hepsiburada'daki güncel durumu için ilan bilgilerine bakın.`;break;default:s=`${n} tarihinde Hepsiburada'ya gönderildi.`}return{line:s,lastCheckedLine:t.lastChecked?`Son kontrol: ${vr(t.lastChecked)}`:void 0,trackingId:t.trackingId}}function Aa(t,n){return t?.length?t.filter(r=>!r.merchantSku||!n||r.merchantSku===n).map(r=>r.message?.trim()).filter(r=>!!r):[]}function Bd(t,n){return Aa(t?.errors,n)}function Dd(t,n){return[...new Set(Aa(t?.warnings,n))]}var{Text:_d}=X,ir=({status:t,reasons:n,unverified:r,unverifiedAt:i,unverifiedLabel:a})=>{const s=sa[t],l=(0,e.jsx)(V,{color:r?"warning":s.tone,"aria-label":r?`${s.label} â doÄrulanamadı`:void 0,style:{margin:0,borderStyle:r?"dashed":void 0,cursor:n?.length||r?"help":void 0},children:s.label});if(r){const d=i?new Date(i):null,g=d&&!Number.isNaN(d.getTime())?`Bu bilgi ${d.toLocaleStr
29ing("tr-TR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})} tarihinde alındı. `:"";return(0,e.jsx)(ne,{title:`${g}${a??"Pazaryeri"} baÄlantısı kesildiÄi için Åu an doÄrulanamıyor.`,children:l})}return n?.length?(0,e.jsx)(ne,{title:(0,e.jsxs)(m,{vertical:!0,gap:2,children:[(0,e.jsx)(_d,{strong:!0,style:{color:"inherit"},children:"Pazaryeri açıklaması"}),n.map((d,g)=>(0,e.jsxs)("span",{children:["⢠",d]},g))]}),children:l}):l},{Text:Te}=X,La={display:"grid",gridTemplateColumns:"minmax(140px, 1.5fr) minmax(120px, 1.2fr) repeat(4, minmax(96px, 1fr)) 76px",columnGap:12,alignItems:"start"},$d=rr,Od=()=>{const{token:t}=J.useToken();return(0,e.jsxs)("div",{style:{...La,padding:"12px 4px 4px"},"aria-hidden":!0,children:[$d.map(n=>(0,e.jsx)(Te,{type:"secondary",style:{fontSize:t.fontSizeSM},children:n.label},n.id)),(0,e.jsx)("span",{})]})},Fd=[{key:"id",label:"Barkod ve stok kodu",md:8},{key:"price",label:"SatıŠfiyatı",md:6},{key:"buybox",label:"Buybox",md:5},{key:"stock",label:"Stok",md:3}],Nd=()=>{const{token:t}=J.useToken();return(0,e.jsx)(_e,{gutter:[16,0],"aria-hidden":!0,style:{padding:"14px 4px 2px"},children:Fd.map(n=>(0,e.jsx)(F,{xs:0,md:n.md,children:(0,e.jsx)(Te,{type:"secondary",style:{fontSize:t.fontSizeSM},children:n.label})},n.key))})},Kd=({listing:t,marketplace:n,index:r,position:i=r,ideasoftStoreName:a,publishStatus:s,docReasons:l,unverified:d,unverifiedLabel:g,isEditing:o,isLast:p})=>{const{token:c}=J.useToken(),{save:u}=ht(),h=Xe[n],x=`${h.name} ${i+1}. ilan`,b=na(t,n),E=ra(t,n),S=aa(t,n),M=Di(n,t,{ideasoftStoreName:a}),j=Bi(n)?"Sitede aç":"Pazaryerinde aç",k=Mi(M),z=da(t),C=s===null||s==="live",L=C?ln(S,c):c.colorTextTertiary,R=[`${h.name}'ya gönderilen deÄer`,"Henüz satıÅta deÄil"],N=E&&E>0&&b>0&&E>b?Math.round((E-b)/E*100):null,de=k?(0,e.jsx)(ne,{title:j,children:(0,e.jsx)(w,{type:"text",href:k,target:"_blank",rel:"noopener noreferrer","aria-label":j,icon:(0,e.jsx)(_,{icon:mt,size:14}),style:{width:32,minWidth:32,padding:0}})}):null,H=s?(0,e.jsx)(ir,{status:s,reasons:Jt(s,l,t),unverified:d,unverifiedAt:typeof t.product=="object"?t.product?.lastSyncedAt:null,unverifiedLabel:g}):null,q={fontSize:c.fontSizeSM},Y=P=>{const v=pt(P);return v?(0,e.jsxs)(Te,{type:"secondary",style:q,children:["Senkron ",v]}):null},I={padding:"16px 4px",borderBottom:p?"none":`1px solid ${c.colorBorderSecondary}`};if(o){const P=A=>`${x} ${A}`,v=(A,ye)=>{const K=fd(n,r,A);return K?(0,e.jsx)("div",{"data-field":jd(n,r,A),children:(0,e.jsx)(W.Item,{name:K,style:{marginBottom:0},children:ye})},A):(0,e.jsx)("div",{},A)};return(0,e.jsxs)("div",{style:{...I,paddingTop:0},"data-field":bi(n,r),"data-inline-editing":"true",onKeyDown:ba(u),children:[(0,e.jsx)(Od,{}),(0,e.jsxs)("div",{style:La,children:[v("barcode",(0,e.jsx)(Le,{"aria-label":P("barkodu"),placeholder:"Barkod",style:{fontFamily:"monospace"}})),v("stockCode",(0,e.jsx)(Le,{"aria-label":P("stok kodu"),placeholder:"Stok kodu"})),v("sale",(0,e.jsx)(Ee,{"aria-label":P("satıŠfiyatı"),min:0,precision:2,suffix:"âº",placeholder:"SatıÅ",style:{width:"100%"}})),v("list",(0,e.jsx)(Ee,{"aria-label":P("liste fiyatı"),min:0,precision:2,suffix:"âº",placeholder:"Liste",style:{width:"100%"}})),v("shippingCost",(0,e.jsx)(Ee,{"aria-label":P("kargo ücreti"),min:0,precision:2,suffix:"âº",placeholder:"Kargo",style:{width:"100%"}})),v("qty",(0,e.jsx)(Ee,{"aria-label":P("stoÄu"),min:0,precision:0,placeholder:"Adet",style:{width:"100%"}})),(0,e.jsx)(m,{justify:"flex-end",children:(0,e.jsx)(tr,{label:x})})]}),(H||t.brandName)&&(0,e.jsxs)(m,{gap:8,align:"center",wrap:"wrap",style:{marginTop:8},children:[H,t.brandName&&(0,e.jsx)(Te,{type:"secondary",style:q,children:t.brandName})]})]})}return(0,e.jsx)("div",{style:I,"data-field":bi(n,r),children:(0,e.jsxs)(_e,{gutter:[16,10],align:"middle",children:[(0,e.jsx)(F,{xs:24,md:8,children:(0,e.jsxs)(m,{vertical:!0,gap:4,children:[(0,e.jsxs)(m,{gap:8,align:"center",wrap:"wrap",children:[(0,e.jsx)(_,{icon:Fs,size:14,color:c.colorTextTertiary}),(0,e.jsx)(Te,{copyable:{icon:(0,e.jsx)(_,{icon:yt,size:12}),tooltips:["Kopyala","Kopyalandı"]},style:{fontFamily:"monospace"},children:t.barcode||"-"}),H]}),(0,e.jsxs)(m,{gap:10,align:"center",wrap:"wrap",children:[t.stockCode&&(0,e.jsxs)(Te,{type:"secondary",style:q,children:[(0,e.jsx)(_,{icon:Ls,size:12})," ",t.stockCode]}),t.brandName&&(0,e.jsx)(Te,{type:"secondary",style:q,children:t.brandName})]})]})}),(0,e.jsx)(F,{xs:12,md:6,children:(0,e.jsxs)(m,{vertical:!0,gap:2,children:[(0,e.jsxs)(m,{align:"baseline",gap:6,children:[(0,e.jsx)(Te,{strong:C,type:C?void 0:"secondary",style:{fontSize:c.fontSizeLG,fontVariantNumeric:"tabular-nums"},children:b>0?`âº${Ae(b)}`:"-"}),N!==null&&(0,e.jsxs)(V,{color:"green",style:{margin:0},children:["-%",N]})]}),E!=null&&E>0&&(0,e.jsxs)(Te,{type:"secondary",delete:N!==null,style:q,children:[N!==null?"":"Liste ","âº",Ae(E)]}),!C&&R.map(P=>(0,e.jsx)(Te,{type:"secondary",style:q,children:P},P)),Y(z.price)]})}),(0,e.jsx)(F,{xs:12,md:5,children:t.buyboxPrice!==void 0?(0,e.jsxs)(m,{align:"center",gap:5,children:[(0,e.jsx)(_,{icon:Li,size:12,color:c.colorSuccess}),(0,e.jsxs)(Te,{style:{color:c.colorSuccess},children:["Buybox âº",Ae(t.buyboxPrice)]})]}):null}),(0,e.jsx)(F,{xs:12,md:3,children:(0,e.jsxs)(m,{vertical:!0,gap:2,children:[(0,e.jsxs)(m,{align:"center",gap:6,children:[(0,e.jsx)("span",{"aria-hidden":!0,style:{width:7,height:7,borderRadius:"50%",background:L,display:"inline-block"}}),(0,e.jsx)(Te,{strong:!0,style:{color:L,fontVariantNumeric:"tabular-nums"},children:S}),(0,e.jsx)(Te,{type:"secondary",style:q,children:"adet"})]}),Y(z.stock)]})}),(0,e.jsx)(F,{xs:12,md:2,children:(0,e.jsxs)(m,{justify:"flex-end",align:"center",gap:4,children:[(0,e.jsx)(ja,{editKey:ac(n,r),label:
29x}),de]})})]})})},{Text:oe}=X,Gn=t=>`pdetail-mp-${t}`,Hd=t=>{const n=t?.product;return typeof n=="string"?n||void 0:n?.id||void 0},Wd=({marketplace:t,listings:n,onOpenPriceHistory:r,publishStatus:i,listingStatuses:a,feedback:s,editingIndex:l=null,listingIndexes:d,onPublishClick:g,onMatchClick:o,onRefresh:p,refreshingMarketplace:c,submission:u,authProblem:h,open:x,onToggle:b})=>{const{token:E}=J.useToken(),{tenant:S}=Qe(),M=nn(),j=S?.marketplaceConfigs?.ideasoft?.storeName??null,k=Xe[t],z=n.length>0,[C,L]=(0,y.useState)(!0),R=x??C,N=(0,y.useMemo)(()=>oa(s),[s]),de=(0,y.useMemo)(()=>ca(s),[s]),H=(0,y.useMemo)(()=>n.map((O,$)=>a[$]??i),[n,a,i]),q=ma(i,a,z),Y=(0,y.useMemo)(()=>{const O=a.find($=>$==="error"||$==="rejected");return O||(i==="error"||i==="rejected"?i:t==="hepsiburada"&&(i==="unpublished"||i==="pending"||a.some($=>$==="unpublished"||$==="pending"))?a.find($=>$==="unpublished"||$==="pending")??(i==="pending"?"pending":"unpublished"):null)},[a,i,t]),I=(0,y.useMemo)(()=>de.map(O=>O.message),[de]),{rawReasons:P,advisoriesConsumedByProblem:v}=(0,y.useMemo)(()=>{if(!Y||Y==="pending")return{rawReasons:[],advisoriesConsumedByProblem:!1};const O=n.flatMap(($,le)=>Jt(H[le]??null,N,$));return O.length>0?{rawReasons:O,advisoriesConsumedByProblem:!1}:N.length>0?{rawReasons:N,advisoriesConsumedByProblem:!1}:{rawReasons:I,advisoriesConsumedByProblem:I.length>0}},[Y,n,H,N,I]),A=(0,y.useMemo)(()=>t==="hepsiburada"?ya(n):null,[t,n]),ye=(0,y.useMemo)(()=>{if(t!=="hepsiburada")return[...new Set(P)];const O=Pr(P);return O.length>0?O:Pr(Bd(u??null,A))},[P,t,u,A]),K=(0,y.useMemo)(()=>t==="hepsiburada"?Dd(u??null,A):[],[t,u,A]),ee=(0,y.useMemo)(()=>{if(t!=="hepsiburada")return null;for(const[O,$]of n.entries()){if(H[O]==="live")continue;const le=Ol($);if(le&&Fl.has(le))return le}return null},[t,n,H]),pe=t==="hepsiburada"&&P.some(Bl),re=!!Y&&(!!ee||pe),xe=pe&&!ee,ge=(0,y.useMemo)(()=>t==="hepsiburada"&&Y?Dl({status:Y,lockedStatus:ee,locked:pe}):null,[t,Y,ee,pe]),ie=(0,y.useMemo)(()=>t==="hepsiburada"&&Y&&u!==void 0?Md(u):null,[t,Y,u]),ue=l!==null,we=!ue&&!!p&&Mo.includes(t),Z=c===t||c==="all",me=we?(0,e.jsx)(ne,{title:`${k.name} durumunu çek`,children:(0,e.jsx)(w,{type:"text",loading:Z,icon:(0,e.jsx)(_,{icon:ut,size:14}),onClick:()=>p?.(t),style:{width:32,height:32,minWidth:32,padding:0},"aria-label":`${k.name} durumunu çek`})}):null,{stock:ae,hasLive:T}=ua(n,H,t),He=n.some((O,$)=>(H[$]??"live")==="live"),ke=O=>{const $=pa({marketplace:t,status:O,hasListings:!1});if($.kind==="match")return(0,e.jsx)(w,{icon:(0,e.jsx)(_,{icon:mt,size:14}),onClick:o,children:$.label});if($.kind!=="publish"&&$.kind!=="retry")return null;const le=re?"Hepsiburada bu aÅamada güncelleme kabul etmiyor â süreç bitene kadar yeniden gönderilemez.":$.disabledReason,$e=(0,e.jsx)(w,{type:"primary",ghost:!0,disabled:!!le,icon:(0,e.jsx)(_,{icon:$.kind==="retry"?ut:an,size:14}),onClick:g,children:$.label});return le?(0,e.jsx)(ne,{title:le,children:(0,e.jsx)("span",{children:$e})}):$e},be={fontSize:E.fontSizeSM},We=Y?(0,e.jsx)(ce,{type:ge?.severity??"error",showIcon:!0,closable:!!ue,style:{margin:"12px 0 4px"},title:ge?.title??(Y==="rejected"?`${k.name} bu ürünü reddetti`:`${k.name} bu ürünü yayınlamadı`),description:(0,e.jsxs)(m,{vertical:!0,gap:8,style:{marginTop:4},children:[ye.length>0?(0,e.jsx)("ul",{style:{margin:0,paddingInlineStart:18},children:ye.map((O,$)=>(0,e.jsx)("li",{children:(0,e.jsx)(oe,{children:O})},$))}):Y==="pending"?null:(0,e.jsx)(oe,{children:"Pazaryeri henüz bir gerekçe döndürmedi. âDurumu Yenileâ ile güncel durumu çekebilirsin."}),ie?(0,e.jsxs)(m,{vertical:!0,gap:2,children:[(0,e.jsxs)(oe,{children:[(0,e.jsx)(oe,{strong:!0,children:"Gönderim durumu: "}),ie.line]}),ie.lastCheckedLine?(0,e.jsx)(oe,{type:"secondary",style:be,children:ie.lastCheckedLine}):null,ie.trackingId?(0,e.jsxs)(oe,{type:"secondary",style:be,children:["Takip ID:"," ",(0,e.jsx)(oe,{copyable:{icon:(0,e.jsx)(_,{icon:yt,size:12}),tooltips:["Kopyala","Kopyalandı"]},style:{...be,fontFamily:"monospace"},children:ie.trackingId})]}):null]}):null,ge?.actionLine?(0,e.jsxs)(oe,{children:[(0,e.jsx)(oe,{strong:!0,children:"Yapılması gereken: "}),ge.actionLine]}):null,ge?.panelUrl&&A?(0,e.jsxs)(oe,{type:"secondary",style:be,children:["SKU:"," ",(0,e.jsx)(oe,{copyable:{icon:(0,e.jsx)(_,{icon:yt,size:12}),tooltips:["Kopyala","Kopyalandı"]},style:{...be,fontFamily:"monospace"},children:A})]}):null,ee?(0,e.jsxs)(oe,{type:"secondary",style:be,children:["Hepsiburada durumu: ",(0,e.jsx)(oe,{strong:!0,style:be,children:ee})]}):null,!ue&&(0,e.jsxs)(m,{gap:8,justify:"flex-end",wrap:"wrap",children:[ge?.panelUrl?(0,e.jsx)(w,{href:ge.panelUrl,target:"_blank",rel:"noopener noreferrer",icon:(0,e.jsx)(_,{icon:mt,size:14}),children:"Hepsiburada'da aç"}):null,(ye.length===0||xe)&&we?(0,e.jsx)(w,{loading:Z,icon:(0,e.jsx)(_,{icon:ut,size:14}),onClick:()=>p?.(t),children:"Durumu Yenile"}):null,Y==="pending"||!z?null:ke(Y)]})]})}):null,Je=K.length>0?(0,e.jsx)(ce,{type:"info",showIcon:!0,closable:!!ue,style:{margin:"12px 0 4px"}
29,title:"Hepsiburada'nın ilan kalitesi notları",description:(0,e.jsxs)(m,{vertical:!0,gap:6,style:{marginTop:4},children:[(0,e.jsx)(oe,{type:"secondary",children:He?"Ãrün Hepsiburada'da satıÅta. Bunlar yayını engellemiyor, düzeltilirse ilanın görünürlüÄü artar.":"Bu notlar Hepsiburada'ya yapılan son yayın gönderimine ait. Ãrünün güncel durumu yukarıda."}),(0,e.jsx)("ul",{style:{margin:0,paddingInlineStart:18},children:K.map((O,$)=>(0,e.jsx)("li",{children:(0,e.jsx)(oe,{children:O})},$))})]})}):null,Ce=de.length>0&&!v?(0,e.jsx)(ce,{type:"warning",showIcon:!0,closable:!!ue,style:{margin:"12px 0 4px"},title:`${k.name} tavsiyesi`,description:(0,e.jsx)("ul",{style:{margin:"4px 0 0",paddingInlineStart:18},children:de.map((O,$)=>{const le=pt(O.at);return(0,e.jsxs)("li",{children:[(0,e.jsx)(oe,{children:O.message}),le?(0,e.jsx)(oe,{type:"secondary",style:{...be,marginInlineStart:8},children:le}):null]},$)})})}):null,et=h?(0,e.jsx)(ce,{type:h.severity,showIcon:!0,style:{margin:"12px 0 4px"},title:(0,e.jsx)(oe,{strong:!0,children:h.title}),description:(0,e.jsxs)(m,{vertical:!0,gap:6,style:{marginTop:4},children:[h.detailLines.map((O,$)=>(0,e.jsx)(oe,{children:O},$)),(0,e.jsxs)(oe,{children:[(0,e.jsx)(oe,{strong:!0,children:"Yapılması gereken: "}),h.actionLine]}),h.settingsPath?(0,e.jsx)(m,{gap:8,justify:"flex-end",wrap:"wrap",style:{marginTop:2},children:(0,e.jsx)(w,{type:"primary",ghost:!0,onClick:()=>M(h.settingsPath),children:"BaÄlantıyı Yenile"})}):null]})}):null,ve=!!(et||We||Je||Ce||z),Ge=ve?(0,e.jsxs)("div",{children:[et,We,Ce,Je,z&&(0,e.jsx)(Nd,{}),n.map((O,$)=>(0,e.jsx)(Kd,{listing:O,marketplace:t,index:d?.[$]??$,position:$,ideasoftStoreName:j,publishStatus:H[$]??null,docReasons:N,unverified:!!h,unverifiedLabel:k.name,isEditing:l===(d?.[$]??$),isLast:$===n.length-1},`${t}-${O.id||O.barcode||$}`))]}):null,lt=(0,e.jsxs)(m,{align:"center",gap:12,wrap:"wrap",justify:"flex-end",children:[!z&&(0,e.jsx)(ir,{status:q,reasons:Jt(q,N),unverified:!!h,unverifiedLabel:k.name}),z&&(0,e.jsxs)(oe,{type:"secondary",style:be,children:[(0,e.jsx)(_,{icon:Ct,size:12})," Stok:"," ",T?(0,e.jsx)(oe,{strong:!0,style:{color:ln(ae,E)},children:ae}):(0,e.jsx)(ne,{title:"Bu pazaryerinde satıÅa girmiÅ ilan yok â reddedilen ilanın taÅıdıÄı miktar stok sayılmıyor.",children:(0,e.jsx)(oe,{strong:!0,style:{color:E.colorTextTertiary},children:"â"})})]}),z&&(0,e.jsxs)(V,{style:{margin:0},children:[n.length," İlan"]}),z&&r&&(0,e.jsx)(w,{type:"link",size:"small",style:{padding:0,height:"auto"},onClick:()=>r(t,n.length===1?Hd(n[0]):void 0),children:"Fiyat geçmiÅi"}),me,!z&&!ue&&ke(q)]}),ot=O=>{L(O),b?.(O)},tt=`${Gn(t)}-body`,D=ve&&R,U=ve?(0,e.jsx)(w,{type:"text","aria-label":R?`${k.name} kartını daralt`:`${k.name} kartını geniÅlet`,"aria-expanded":R,"aria-controls":tt,onClick:()=>ot(!R),icon:(0,e.jsx)(_,{icon:R?_n:Rs,size:16}),style:{width:32,height:32,minWidth:32,padding:0}}):null;return(0,e.jsx)(Me,{id:Gn(t),"data-testid":`marketplace-card-${t}`,title:(0,e.jsxs)(m,{align:"center",gap:4,children:[U,(0,e.jsx)(Qt,{marketplace:t,height:22,muted:!z})]}),extra:lt,styles:{header:{background:E.colorFillQuaternary,borderBottom:D?`1px solid ${E.colorBorderSecondary}`:"none",padding:"8px 12px",minHeight:0},body:D?{padding:"8px 20px 12px"}:{display:"none"}},style:{borderRadius:E.borderRadiusLG,border:`1px solid ${E.colorBorderSecondary}`,overflow:"hidden",scrollMarginTop:124},children:D?(0,e.jsx)("div",{id:tt,children:Ge}):null})},{Text:Fe}=X,ji=t=>t?t.min===t.max?`âº${Ae(t.min)}`:`âº${Ae(t.min)} â âº${Ae(t.max)}`:"â",Gd=({rows:t,ideasoftStoreName:n,isEditing:r,onOpen:i,onPublish:a,onMatch:s})=>{const{token:l}=J.useToken(),d=(0,y.useMemo)(()=>t.map(c=>{const{marketplace:u,listings:h,publishStatus:x,listingStatuses:b,feedback:E}=c,S=h.length>0,M=h.map((q,Y)=>b[Y]??x),j=ma(x,b,S),k=oa(E),z=E.find(q=>q.kind!=="advisory"),C=ca(E)[0],L=z??C,R=L?{text:la(L),tone:L.kind==="advisory"?"warning":"error",at:pt(L.at)}:null,{stock:N,hasLive:de}=ua(h,M,u),H=h.map(q=>Mi(Di(u,q,{ideasoftStoreName:n}))).find(Boolean);return{key:u,marketplace:u,linked:S,status:j,statusReasons:S?[]:Jt(j,k),note:R,listingCount:h.length,sale:$r(h.map(q=>na(q,u))),list:$r(h.map(q=>ra(q,u)??0)),stock:S&&de?N:null,lastSync:pt(Po(h)),action:pa({marketplace:u,status:j,hasListings:S,listingUrl:H??null,ownStorefront:Bi(u)})}}),[t,n]),g={fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},o={fontSize:l.fontSizeSM},p=c=>{const{action:u,marketplace:h}=c;if(u.kind==="none")return null;if(u.kind==="open")return(0,e.jsx)(w,{type:"link",href:u.href,target:"_blank",rel:"noopener noreferrer",icon:(0,e.jsx)(_,{icon:mt,size:14}),style:{padding:0},onClick:b=>b.stopPropagation(),children:"Aç"});if(r)return null;if(u.kind==="match")return(0,e.jsx)(w,{type:"link",icon:(0,e.jsx)(_,{icon:mt,size:14}),style:{padding:0},onClick:b=>{b.stopPropagation(),s()},children:u.label});const x=(0,e.jsx)(w,{type:"link",disabled:!!u.disabledReason,icon:(0,e.jsx)(_,{icon:u.kind==="retry"?ut:an,size:14}),style:{padding:0},onClick:b=>{b.stopPropagation(),a(h)},children:u.label});
29return u.disabledReason?(0,e.jsx)(ne,{title:u.disabledReason,children:(0,e.jsx)("span",{onClick:b=>b.stopPropagation(),children:x})}):x};return(0,e.jsx)(Pt,{size:"middle",columns:[{title:"Pazaryeri",key:"marketplace",width:200,render:(c,u)=>(0,e.jsx)(w,{type:"text",onClick:h=>{h.stopPropagation(),i(u.marketplace)},"aria-label":`${u.marketplace} kartına git`,style:{padding:"0 4px",height:"auto"},children:(0,e.jsx)("span",{style:{whiteSpace:"nowrap"},children:(0,e.jsx)(Qt,{marketplace:u.marketplace,height:16,muted:!u.linked})})})},{title:"Durum",key:"status",render:(c,u)=>(0,e.jsxs)(m,{vertical:!0,gap:2,align:"flex-start",children:[(0,e.jsx)(ir,{status:u.status,reasons:u.statusReasons}),u.note&&(0,e.jsx)(ne,{title:u.note.text,children:(0,e.jsxs)(Fe,{type:u.note.tone==="error"?"danger":"warning",ellipsis:!0,style:{...o,maxWidth:240},children:[u.note.text,u.note.at?(0,e.jsx)(Fe,{type:"secondary",style:{...o,marginInlineStart:6},children:u.note.at}):null]})})]})},{title:"İlan",dataIndex:"listingCount",key:"listingCount",width:56,align:"right",render:c=>(0,e.jsx)(Fe,{style:g,children:c>0?c:"â"})},{title:"SatıŠfiyatı",key:"sale",width:110,align:"right",render:(c,u)=>(0,e.jsx)(Fe,{style:g,children:ji(u.sale)})},{title:"Liste fiyatı",key:"list",width:110,align:"right",render:(c,u)=>(0,e.jsx)(Fe,{type:"secondary",style:g,children:ji(u.list)})},{title:"Stok",key:"stock",width:64,align:"right",render:(c,u)=>u.stock===null?(0,e.jsx)(Fe,{type:"secondary",children:"â"}):(0,e.jsx)(Fe,{strong:!0,style:{...g,color:ln(u.stock,l)},children:u.stock})},{title:"Son senkron",key:"lastSync",width:128,render:(c,u)=>u.lastSync?(0,e.jsx)(Fe,{type:"secondary",style:{...o,...g},children:u.lastSync}):(0,e.jsx)(Fe,{type:"secondary",children:"â"})},{title:"Eylem",key:"action",width:124,align:"right",render:(c,u)=>(0,e.jsx)("span",{style:{whiteSpace:"nowrap"},children:p(u)})}],dataSource:d,pagination:!1,rowClassName:c=>c.linked?"":"pdetail-mp-row-muted",onRow:c=>({onClick:()=>i(c.marketplace),style:{cursor:"pointer",opacity:c.linked?1:.7},"data-testid":`mp-summary-row-${c.marketplace}`}),scroll:{x:"max-content"},"aria-label":"Pazaryeri özeti"})};function Yd(t){const n=new Set,r=[],i=(a,s)=>{if(!a)return;const l=a?.url?.trim();!l||n.has(l)||(n.add(l),r.push({url:l,order:typeof a.order=="number"?a.order:s,altText:a.altText,source:a.source,tags:a.tags}))};for(const a of t.images||[])i(a,r.length);return t.primaryImage&&i({url:t.primaryImage,order:r.length===0?0:r.length,altText:t.title},r.length),r.sort((a,s)=>(a.order??0)-(s.order??0))}var{Title:Bn,Text:Ne}=X;function Ud(t){return Object.fromEntries(it.map(n=>[n,(t[n]??[]).map(r=>({...r}))]))}function Vd(t){return{title:t.title,canonicalBarcode:t.canonicalBarcode??void 0,canonicalStockCode:t.canonicalStockCode??void 0,purchasePrice:t.purchasePrice??void 0,purchaseCurrency:Be(t.purchaseCurrency),stock:t.stock??void 0,desi:t.desi??void 0,maxDesi:t.maxDesi??void 0,desiPreference:t.desiPreference??"marketplaceFirst",shippingCost:t.shippingCost??void 0,additionalExpenses:(t.additionalExpenses??[]).map(n=>{const r=sn(n.supplyItem);return{...n,mode:n.mode??"fixed",...r?{supplyItem:r}:{}}})}}var qd={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},Zd=[{title:"Ãrün",dataIndex:"title",key:"title",ellipsis:!0,render:(t,n)=>n.id?(0,e.jsx)(hs,{to:`/products/${n.id}`,children:t}):(0,e.jsx)(Ne,{children:t})},{title:"Adet",dataIndex:"quantity",key:"quantity",width:90,align:"center",render:t=>(0,e.jsx)(V,{color:"geekblue",children:t})},{title:"Stok",dataIndex:"stock",key:"stock",width:110,align:"center",render:t=>t==null?(0,e.jsx)(Ne,{type:"secondary",children:"-"}):(0,e.jsx)(V,{color:To(t),children:t})}],vi={"/set-product-matching":"Set Ãrün EÅleÅtirme","/product-matching":"Ãrün EÅleÅtirme","/products":"Ãrünler"},Ru=()=>{const{id:t}=gs(),n=nn(),r=Ti(),i=r.state?.from??null,a=i&&i in vi?i:"/products",s=vi[a]??"Ãrünler",l=(0,y.useCallback)(()=>{r.key!=="default"?n(-1):n(a)},[r.key,n,a]),{message:d,modal:g}=st.useApp(),{token:o}=J.useToken(),{tenant:p,loading:c}=Qe(),u=p?.b2bEnabled===!0,[h,x]=(0,y.useState)(null),b=h!==null,E=At(h),[S,M]=(0,y.useState)(!1),j=(0,y.useRef)(!1),k=(0,y.useRef)(null),[z,C]=(0,y.useState)(null),[L]=W.useForm(),[R,N]=(0,y.useState)(null),[de,H]=(0,y.useState)(()=>new Set),[q,Y]=(0,y.useState)(!1),[I,P]=(0,y.useState)(null),[v,A]=(0,y.useState)(!1),[ye,K]=(0,y.useState)(!1),{user:ee}=Qe(),{isTenantAdmin:pe,canWrite:re}=As(),xe=wl({includeArchived:!0}),ge=Tl(),ie=async f=>{try{const B=wt(f).trim(),G=El(xe.data,f,B);if(G)return d.info(`Mevcut â${G.name}â sarf tanımı kullanıldı`),G;const Q=Number(f.amount)||0,Se=await ge.mutateAsync({name:B,unit:"adet",currency:Be(f.currency),vatIncluded:!1,vatRate:20,price:Q,effectiveFrom:Xn()});return d.success(`â${Se.name}â sarf tanımı oluÅturuldu`),{...Se,currentPrice:Q}}catch(B){throw d.error(B instanceof Cl?"Tanım oluÅturuldu, fiyat kaydedilemedi â fiyatı Sarf Malzemeleri ekranından ekleyin":Ps(B)),B}},{data:ue}=jn({queryKey:["marketplace-config",p?.id??null],channel:Ie.TENANT.CHECK_MARKETPLACE_AUTH,params:{tenantId:p?.id??""},enabled:!!p?.id&&pe,throwOnError:!1}),{data:we,isLoading:Z,isRefetching:me,refetch:ae}=jn({queryKey:[...gl(t??""),p?.id],channel:Ie.PAYLOAD.GET_PRODUCT_DETAILS,params:{where:{and:[{id:{equals:t}},...p?.id?[{tenant:{equals:p.id}}]:[]]},...Nl,limit:1},enabled:!!t&&!c&&!!p?.id,staleTime:0,refetchOnMount:"always"}),T=we?.docs?.[0],He=za("horizontal"),{jumpTo:ke}=Ld(!!T,He),{data:be}
29=Vi(T?.id),We=(be?.parents?.length??0)>0,Je=hl(),Ce=(0,y.useCallback)(()=>{L.resetFields(),N(null),P(null),x(null)},[L]),et=xr({channel:Ie.PAYLOAD.UPDATE_PRODUCT_DETAILS,onSuccess:async()=>{await ae(),await Promise.all(zs.map(f=>vn([f]))),d.success("Ãrün bilgileri güncellendi"),Ce(),M(!1)},onError:f=>{const B=Td(f),G=k.current,Q=G?B.filter(te=>oc(G,te.name)):[],Se=B.filter(te=>!Q.includes(te)),Oe=j.current?"Fiyatlar pazaryerlerine gönderildi, ancak diÄer alanlar kaydedilemedi.":null;Q.length>0&&(L.setFields(Q),L.scrollToField(Q[0].name,{block:"center"}));const se=B.length===0?[f.message]:Se.map(te=>`${Sd(te.name)}: ${te.errors.join(" ")}`);P([Oe,...se].filter(Boolean).join(" ")||null),M(!1)}}),[ve,Ge]=(0,y.useState)(null),lt=xr({channel:Ie.PRODUCT_DETAIL.REFRESH,onSuccess:async f=>{if(await ae(),await vn([Or]),f?.summary?.failed&&f.summary.failed>0){const B=f.results?.find(Q=>Q.errorCode==="AUTH_ERROR");if(B){d.error(B.error||"Pazaryeri baÄlantısı kesildi â Ayarlar â Pazaryerleri bölümünden yeniden yetkilendirin."),Ge(null);return}const G=f.results?.find(Q=>!Q.success&&Q.error)?.error;d.warning(G||"Bazı pazaryerleri güncellenemedi")}else if(f?.summary?.total===0){const B=ve&&ve!=="all"?Ve(ve):null;d.info(B?`${B} tarafında bu ürüne ait kayıt bulunamadı.`:"Güncellenecek pazaryeri kaydı bulunamadı")}else d.success("Pazaryeri durumu güncellendi");Ge(null)},onError:f=>{d.error(`Yenileme hatası: ${f.message}`),Ge(null)},onSettled:()=>{vn(["marketplace-config",p?.id??null])}}),ot=f=>{!T||lt.isPending||(Ge(f??"all"),lt.mutate({id:T.id,...f?{marketplace:f}:{}}))},tt=async()=>{try{return(await ae()).data?.docs?.[0]??T}catch{return T}},D=f=>{for(const{reason:B,text:G}of[{reason:"no-sale-price",text:"satıŠfiyatı olmadan üstü çizili fiyat gönderilemez"},{reason:"no-server-row",text:"ilan sunucuda bulunamadı"}]){const Q=f.filter(te=>te.reason===B);if(Q.length===0)continue;const Se=[...new Set(Q.map(te=>`${Ve(te.marketplace)}${te.identifier?` (${te.identifier})`:""}`))],Oe=Se.slice(0,3).join(", "),se=Se.length>3?` ve ${Se.length-3} ilan daha`:"";d.warning(`${Oe}${se}: ${G}, fiyat deÄiÅikliÄi uygulanmadı.`)}},U=f=>{if(!T||S||h===f)return;const B=()=>{const G={...Vd(T),...Ud(T)};L.resetFields(),L.setFieldsValue(G),N(G),P(null),x(f)};if(ct){g.confirm({title:"KaydedilmemiÅ deÄiÅiklik var",content:`${xt??"Açık alanda deÄiÅiklik var"}. Bırakıp bu alanı açmak istiyor musunuz?`,okText:"Bırak ve aç",okButtonProps:{danger:!0},cancelText:"Geri dön",onOk:B});return}B()},$=uo(async()=>{if(!T||!h||S)return;P(null);try{await L.validateFields(sc(h),{recursive:!0})}catch(se){const te=se?.errorFields?.[0]?.name;te&&L.scrollToField(te,{block:"center"}),d.warning("Formda düzeltilmesi gereken alanlar var");return}if(!cc(h,Rt,Mt)){Ce();return}const f=lc(h,L.getFieldsValue(!0),{isBundle:T.isBundle});if(Object.keys(f).length===0){Ce();return}M(!0),j.current=!1,k.current=h;const B=await tt(),{edits:G,sanitized:Q,skipped:Se}=ho(B,f);D(Se);const Oe=se=>{M(!0),et.mutate({id:T.id,...se})};if(G.length===0){Oe(Qi(B,Q));return}g.confirm({title:"Fiyat deÄiÅikliÄini onayla",width:520,okText:"Kaydet ve gönder",cancelText:"Vazgeç",content:(0,e.jsxs)(Ht,{orientation:"vertical",size:8,style:{width:"100%"},children:[(0,e.jsx)(Ne,{type:"secondary",children:"AÅaÄıdaki ilan fiyatları pazaryerlerine gönderilecek. Bu iÅlem geri alınamaz."}),G.map(se=>(0,e.jsxs)(Ne,{children:[(0,e.jsx)(Ne,{strong:!0,children:Ve(se.marketplace)}),se.identifier?` (${se.identifier})`:"",":"," ",se.currentSalePrice!==void 0?`âº${Ae(se.currentSalePrice)}`:"â"," ","â ",(0,e.jsxs)(Ne,{strong:!0,children:["âº",Ae(se.salePrice)]})]},`${se.marketplace}:${se.listingIndex}`))]}),onOk:async()=>{const se=await go({edits:G,body:Q,push:te=>Je.mutateAsync({productId:String(T.id),marketplace:te.marketplace,salePrice:te.salePrice,listPrice:te.listPrice,listingIndex:te.listingIndex}),readServerProduct:tt});if(j.current=se.pushed,se.failures.length>0){const te=[...new Set(se.failures)].map(Ve);d.error(`Fiyat gönderilemedi: ${te.join(", ")}`)}else d.success("Fiyatlar pazaryerlerine gönderildi");Oe(se.body)},onCancel:()=>M(!1)})}),{marketplaceGroups:le,activeMarketplaces:$e}=(0,y.useMemo)(()=>
29{if(!T)return{marketplaceGroups:[],activeMarketplaces:[]};const f=[],B=[],G=[];for(const Q of it){const Se=Fr(p,Q),Oe=T[Q]??[],se=qs(T,Q)?Oe.flatMap((bn,ps)=>bn.barcode?[ps]:[]):[],te=se.map(bn=>Oe[bn]);!Se&&te.length===0||(te.length>0?(f.push({marketplace:Q,listings:te,rawIndexes:se}),G.push(Q)):Se&&B.push({marketplace:Q,listings:te,rawIndexes:se}))}return{marketplaceGroups:[...f,...B],activeMarketplaces:G}},[T,p]),Ra=(0,y.useMemo)(()=>le.filter(f=>Fr(p,f.marketplace)&&Gt(f.marketplace)!=="none").map(f=>f.marketplace),[le,p]),Lt=(0,y.useMemo)(()=>le.find(f=>f.marketplace==="hepsiburada")?.listings??[],[le]),pn=(0,y.useMemo)(()=>ya(Lt),[Lt]),Ma=(0,y.useMemo)(()=>Ao(T?.publishStatus?.hepsiburada??null,Lt),[T,Lt]),{data:Ba,isSuccess:Da}=jn({queryKey:[Or,t,p?.id,pn],channel:Ie.HEPSIBURADA.LIST_UPLOADS,params:{tenantId:p?.id,productDetailId:t,...pn?{merchantSku:pn}:{},limit:1},enabled:!!t&&!c&&!!p?.id&&Ma,throwOnError:!1}),_a=Da?Ba?.items?.[0]??null:void 0,ar=(0,y.useMemo)(()=>!T?.isBundle||!T.bundleItems?[]:T.bundleItems.map((f,B)=>{const G=typeof f.productDetail=="object"?f.productDetail:null,Q=G?.id??(typeof f.productDetail=="string"?f.productDetail:null);return{key:`bundle-${B}`,id:Q,title:G?.title??Q??"-",quantity:f.quantity,stock:G?.stock??null}}),[T]),sr=(0,y.useMemo)(()=>T?Yd(T):[],[T]),$a=T?.buyboxTrackingEnabledMarketplaces??[],lr=T&&($l(T)||T.canonicalBarcode)||"",ft=W.useWatch([],{form:L,preserve:!0}),Rt=(0,y.useMemo)(()=>b?xd(R??void 0,ft):[],[b,R,ft]),Mt=(0,y.useMemo)(()=>b?kd(R??void 0,ft):[],[b,R,ft]),hn=Rt.length+Mt.length,ct=b&&hn>0,Oa=[...Rt.map(f=>yn[f].label),...Mt.map(f=>f.label)],xt=hn>0?`${hn} alan deÄiÅti (${Oa.join(", ")})`:void 0,or=Cd(ct,{description:xt}),Fa=(0,y.useCallback)(()=>{or().then(f=>{f&&l()})},[or,l]),Na=(0,y.useCallback)(()=>{if(!ct){Ce();return}g.confirm({title:"DeÄiÅiklikler iptal edilsin mi?",content:`${xt??"KaydedilmemiÅ deÄiÅiklik var"}. Düzenlemeden çıkarsanız kaybolur.`,okText:"İptal et",okButtonProps:{danger:!0},cancelText:"Düzenlemeye dön",onOk:()=>Ce()})},[ct,xt,Ce,g]),[,cr]=Yn("priceSeries",Ei.withDefault("")),dr=(0,y.useCallback)(f=>{cr(f||null),ke("fiyat-gecmisi")},[cr,ke]),{isOpen:Ka,request:ur,settle:Bt}=wd(),Ha=(0,y.useCallback)(()=>ct?ur():Promise.resolve(!0),[ct,ur]);if(Z)return(0,e.jsx)(wn,{children:(0,e.jsx)($c,{})});if(!T)return(0,e.jsx)(wn,{children:(0,e.jsxs)(m,{vertical:!0,gap:16,style:{width:"100%",padding:"0 4px"},children:[(0,e.jsxs)(er,{children:[(0,e.jsx)(w,{type:"text","aria-label":`${s} sayfasına dön`,icon:(0,e.jsx)(_,{icon:$n,size:18}),onClick:l,style:{width:32,height:32,minWidth:32,padding:0}}),(0,e.jsx)(Ne,{strong:!0,style:{flex:1},children:"Ãrün bulunamadı"}),(0,e.jsx)(w,{icon:(0,e.jsx)(_,{icon:ut,size:14}),onClick:()=>{ae()},loading:me,children:"Yenile"})]}),(0,e.jsxs)(m,{vertical:!0,align:"center",gap:16,style:{padding:48},children:[(0,e.jsx)(fe,{description:"Ãrün bulunamadı ya da bu maÄazaya ait deÄil"}),(0,e.jsx)(w,{icon:(0,e.jsx)(_,{icon:$n}),onClick:l,children:s==="Ãrünler"?"Ãrünlere Dön":`${s}'e Dön`})]})]})});const mr=it.map(f=>T[f]?.find(B=>B.stockCode)?.stockCode).find(Boolean)??T.canonicalStockCode??"",yr=u&&T.b2b?.enabled,Wa=T.isBundle||yr?(0,e.jsxs)(m,{gap:8,align:"center",wrap:"wrap",children:[T.isBundle&&(0,e.jsxs)(V,{color:"geekblue",icon:(0,e.jsx)(_,{icon:Ct,size:12}),style:{margin:0},children:["Set Ãrün · ",T.bundleItems?.length||0," ürün"]}),yr&&(0,e.jsx)(V,{color:"gold",style:{margin:0},children:"B2B Aktif"})]}):null,gn=f=>{Gt(f)==="flow"&&C(f)},Ga=Ra.map(f=>{const B=Xe[f],G=Gt(f)==="soon";return{key:f,label:(0,e.jsxs)(m,{align:"center",gap:8,children:[(0,e.jsx)(_i,{id:f,name:B.name,height:14}),(0,e.jsx)("span",{children:B.name}),G&&(0,e.jsx)(V,{style:{margin:0},children:"yakında"})]}),disabled:G,onClick:()=>gn(f)}}),pr=f=>{H(B=>{if(!B.has(f))return B;const G=new Set(B);return G.delete(f),G}),$e.includes(f)||Y(!0),requestAnimationFrame(()=>{document.getElementById(Gn(f))?.scrollIntoView({behavior:"smooth",block:"start"})})},Ya=(f,B)=>{H(G=>{const Q=new Set(G);return B?Q.delete(f):Q.add(f),Q})},Ua=pe,hr=!!T.isBundle||We,Va=new Set(hr?[]:["set"]),qa=cn.filter(f=>!Va.has(f.id)),Za={pazaryerleri:`${$e.length}/${le.length}`},Qa=b?bd(Rt,Mt):void 0,Xa=h==="title"?ft?.title?.trim()||"Ãrün adı boÅ":Vs(T),Ja=le.filter(f=>f.listings.length>0).map(f=>({marketplace:f.marketplace,status:f.listings.map(B=>zr(f.marketplace,B)).find(B=>B!==null)??T.publishStatus?.[f.marketplace]??"live"})),es=Wn(T.purchasePrice,T.purchaseCurrency,T.additionalExpenses),fn={fontVariantNumeric:"tabular-nums"},ts=[{key:"listings",label:"Aktif ilan",children:(0,e.jsxs)("span",{style:fn,children:[$e.length," / ",le.length]})},{key:"unitCost",label:"Birim maliyet",children:(0,e.jsx)("span",{style:fn,children:Sa(es)})},{key:"desi",label:"Desi",children:(0,e.jsx)("span",{style:fn,children:T.desi??"â"})},...T.brand?[{key:"brand",label:"Marka",children:T.brand}]:[]],ns=f=>(0,e.jsx)(kc,{product:T,form:L,identity:f,supplyItems:xe.data,supplyItemsLoading:xe.isLoading,supplyItemsError:xe.isError,onConvertExpense:ie,onOpenPriceHistory:()=>dr("cost"),catalogPricing:(0,e.jsx)(Gl,{product:T,productId:String(T.id),canWrite:re,onApplied:()=>{ae()}})}),Dt=()=>n(`/product-matching?matchProductId=${T.id}`),rs=p?.marketplaceConfigs?.ideasoft?.storeName??null,xn=le.map(f=>({marketplace:f.marketplace,rawIndexes:f.rawIndexes,listings:f.listings,publishStatus:T.publishStatus?.[f.marketplace]??null,listingStatuses:f.listings.map(B=>zr(f.marketplace,B)),feedback:Co(T.publishErrors?.[f.marketplace])})),is=xn.filter(f=>f.listings.length>
290),kn=xn.filter(f=>f.listings.length===0),gr=f=>(0,e.jsx)(Wd,{marketplace:f.marketplace,listings:f.listings,publishStatus:f.publishStatus,listingStatuses:f.listingStatuses,feedback:f.feedback,editingIndex:E?.marketplace===f.marketplace?E.index:null,listingIndexes:f.rawIndexes,onOpenPriceHistory:(B,G)=>dr(G?xl(B,G):B),onPublishClick:()=>gn(f.marketplace),onMatchClick:Dt,onRefresh:ot,refreshingMarketplace:ve,submission:f.marketplace==="hepsiburada"?_a:void 0,authProblem:yo({marketplace:f.marketplace,marketplaceLabel:Xe[f.marketplace]?.name??f.marketplace,authStatus:ue?.marketplaceConfigs?.[f.marketplace]?.authStatus,lastVerifiedAt:Lo(f.listings),canReauthorize:pe}),open:!de.has(f.marketplace),onToggle:B=>Ya(f.marketplace,B)},f.marketplace),as=(0,e.jsx)(Ue,{section:"pazaryerleri",count:`${$e.length}/${le.length}`,extra:(0,e.jsxs)(m,{align:"center",gap:12,wrap:"wrap",children:[!b&&(0,e.jsx)(w,{"data-guide":"product-detail-marketplaces-refresh",loading:ve==="all",icon:(0,e.jsx)(_,{icon:ut,size:14}),onClick:()=>ot(),children:"Tüm Pazaryerlerini Güncelle"}),$e.length<le.length&&(0,e.jsx)(w,{"data-guide":"product-detail-matching-link",type:"link",icon:(0,e.jsx)(_,{icon:mt,size:14}),onClick:()=>n(`/product-matching?matchProductId=${T.id}`),style:{padding:0},children:"EÅleÅtirme sayfası â"})]}),children:le.length===0?(0,e.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:"Bu maÄazada tanımlı pazaryeri yok"}):(0,e.jsxs)(m,{vertical:!0,gap:16,children:[(0,e.jsx)(Gd,{rows:xn,ideasoftStoreName:rs,isEditing:b,onOpen:pr,onPublish:gn,onMatch:Dt}),is.map(gr),kn.length>0&&(0,e.jsx)(js,{ghost:!0,activeKey:q?["unlinked"]:[],onChange:f=>Y(f.length>0),items:[{key:"unlinked",label:(0,e.jsxs)(Ne,{strong:!0,children:["BaÄlı olmayan pazaryerleri (",kn.length,")"]}),children:(0,e.jsx)(m,{vertical:!0,gap:12,children:kn.map(gr)})}]})]})}),ss=(0,e.jsxs)(Ue,{section:"fiyat-gecmisi",children:[(0,e.jsx)(yd,{productId:T.id,canWrite:re,beforeMutate:Ha}),(0,e.jsx)(zt,{open:Ka,title:"KaydedilmemiŠürün deÄiÅiklikleri var",onCancel:()=>Bt(!1),footer:[(0,e.jsx)(w,{onClick:()=>Bt(!1),children:"Geri dön"},"back"),(0,e.jsx)(w,{danger:!0,onClick:()=>{Ce(),Bt(!0)},children:"DeÄiÅiklikleri bırak"},"discard"),(0,e.jsx)(w,{type:"primary",loading:S,onClick:()=>{Bt(!1),$()},children:"Kaydet"},"save")],children:(0,e.jsx)(Ne,{children:`${xt??"KaydedilmemiÅ deÄiÅiklik var"}. Fiyat geçmiÅi kaydı ayrı bir iÅlemdir ve ürün formundaki deÄiÅiklikleri göndermez. Kaydederseniz panel kapanır; kayıt bittikten sonra baÄlantıya yeniden basın.`})})]}),ls=(0,e.jsx)(gd,{product:T,canEditDesiPreference:pe,buyboxMarketplaces:$a,tagsSlot:(0,e.jsx)(pl,{productId:T.id,tags:T.tags,canWrite:re})}),fr="pdetail-stok-fiyat",_t="pdetail-kimlik",os=(0,e.jsxs)("section",{id:_t,"data-guide":_t,"aria-labelledby":`${_t}-title`,style:{scrollMarginTop:124},children:[(0,e.jsx)(Bn,{id:`${_t}-title`,level:4,style:{margin:"0 0 16px",fontSize:o.fontSizeLG,fontWeight:600},children:Nn.kimlik}),ls]}),cs=(0,e.jsx)(Ue,{section:"bilgiler",children:(0,e.jsx)("section",{id:fr,"data-guide":fr,"aria-label":Nn["stok-fiyat"],style:{scrollMarginTop:124,padding:20,borderRadius:o.borderRadiusLG,border:`1px solid ${o.colorBorderSecondary}`,background:o.colorFillQuaternary},children:ns(os)})}),ds=(0,e.jsx)(Dc,{title:T.title,images:sr,primaryBarcode:lr,primarySku:mr,summaryItems:ts,badges:Wa,showAddMarketplace:$e.length<it.length,onAddMarketplace:Dt,gallery:(0,e.jsx)(Lc,{productId:T.id,initialImages:sr})}),us={editingKey:h,saving:S,canWrite:re,start:U,save:()=>{$()},cancel:Na},ms=hr&&(0,e.jsx)(Ue,{section:"set",extra:(0,e.jsx)(w,{type:"link",onClick:()=>n(`/variant-management?variantProductId=${T.id}`),style:{padding:0},children:"Varyant grubu â"}),children:(0,e.jsxs)(Ht,{orientation:"vertical",style:{width:"100%"},size:16,children:[(0,e.jsx)(Tc,{productId:T.id,hideWhenEmpty:!0}),T.isBundle&&(0,e.jsxs)(m,{vertical:!0,gap:12,children:[(0,e.jsxs)(m,{align:"center",gap:8,children:[(0,e.jsx)(_,{icon:Ct,size:16,color:o.colorTextSecondary}),(0,e.jsx)(Bn,{level:4,style:{margin:0,fontSize:o.fontSize,fontWeight:600},children:"Set ürün bileÅenleri"}),(0,e.jsxs)(V,{color:"geekblue",style:{margin:0},children:[ar.length," ürün"]})]}),(0,e.jsx)(Pt,{dataSource:ar,columns:Zd,pagination:!1,size:"middle"})]})]})}),ys=(0,e.jsx)(Ue,{section:"gecmis",extra:(0,e.jsx)(w,{type:"link",onClick:()=>A(!0),style:{padding:0},children:"Aktivite kaydı â"}),children:(0,e.jsxs)(Ht,{orientation:"vertical",style:{width:"100%"},size:16,children:[(0,e.jsx)(Ac,{productId:T.id}),(0,e.jsx)(to,{productId:T.id,hideWhenEmpty:!0})]})});return(0,e.jsxs)(wn,{children:[(0,e.jsx)(dc,{value:us,children:(0,e.jsx)(W,{form:L,layout:"vertical",component:!1,disabled:S,requiredMark:!1,children:(0,e.jsxs)(m,{vertical:!0,gap:16,style:{width:"100%",padding:"0 4px"},children:[(0,e.jsx)(Go,{productId:T.id,title:Xa,imageUrl:T.primaryImage,primaryBarcode:lr,primarySku:mr,chips:Ja,onChipClick:pr,editing:b,canWrite:re,backLabel:s,onBack:Fa,onPublishShortcut:()=>ke("pazaryerleri"),publishActions:Ga,onMatch:Dt,onOpenVariantGroup:()=>n(`/variant-management?variantProductId=${T.id}`),onOpenSetProducts:()=>n(`/set-product-matching?setProductId=${T.id}`),onOpenActivity:()=>A(!0),onOpenProfit:()=>K(!0),onRefresh:()=>{ae()},refreshing:me,onCloned:f=>n(`/products/${f}`)}),(0,e.jsx)(Bn,{level:2,style:qd,children:"Ãrün detayı"}),I&&(0,e.jsx)(ce,{type:"error",showIcon:!0,closable:!0,title:"Kaydedilemedi",description:I,onClose:()=>P(null)}),(0,e.jsx)(Ad,{sections:qa,direction:"horizontal",counts:Za,changedCounts:Qa}),(0,e.jsxs)(m,{vertical:!0,gap:24,style:{minWidth:0},children:[ds,cs,as,ss,ms,ys]})]})})}),(0,e.jsx)(tc,{productId:T.id,open:v,onClose:()=>A(!1),currentUserId:ee?.id,isAdmin:Ua}),(0,e.jsx)(vc,{productId:T.id,additionalExpenses:T.additionalExpenses,supplyItems:xe.data,open:ye,onClose:()=>K(!1)}),(0,e.jsx)(_l,{open:z!==null,product:T,marketplace:z??"trendyol",onClose:()=>C(null),onSuccess:()=>{ae()}})]})};export{Vd as buildFormValues,Ru 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.