1import{c as h,g as b,j as c,I as _}from"./app-BI-V7AHb.js";import{A as x}from"./analytics-DaAfaNqP.js";import{ProductScoreDialog as k}from"./ProductScoreDialog-YIlT-ryh.js";import{ActionButton as A}from"./ActionButton-DCYM06iT.js";import"./drawer-BV75XRXt.js";import"./ProductScoreUnavailable-D5WVfGyC.js";import"./ProductScoreFamily-sRY1wRXL.js";import"./progress-Zbazf3RM.js";import"./circle-alert-DPDSevOa.js";import"./use_is_mobile-B0Ch3wwz.js";import"./refresh-cw-BVnfowNf.js";const S=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],E=h("Gauge",S),O=100,C=1/3;function m(e,r){for(const[n,t]of r)if(e>=n)return t;return 0}const I={key:"profitability",label:"Rentabilité",maxPoints:35,criteria:[{key:"net_margin",label:"Marge nette",maxPoints:20,source:"prices",inputs:["netMarginPercent"],measure:({netMarginPercent:e})=>e===null?null:m(e,[[30,20],[25,16],[20,12],[15,6]])},{key:"net_roi",label:"ROI net",maxPoints:15,source:"prices",inputs:["netRoiPercent"],measure:({netRoiPercent:e})=>e===null?null:m(e,[[60,15],[45,12],[30,9],[25,4]])}]},v={key:"market_access",label:"Accès au marché",maxPoints:27,criteria:[{key:"amazon_absent",label:"Amazon absent",maxPoints:12,source:"product",inputs:["amazonPresence"],measure:({amazonPresence:e})=>e===null?null:e==="never"?12:e==="occasional"?6:0},{key:"brand_not_selling",label:"Marque pas vendeuse",maxPoints:8,source:"crossed",inputs:["brandIsSelling"],measure:({brandIsSelling:e})=>e===null?null:e?0:8},{key:"right_to_sell",label:"Droit de vendre",maxPoints:4,source:"external",inputs:["rightToSell"],measure:({rightToSell:e})=>e===null?null:e==="allowed"?4:0},{key:"hazardous_material",label:"Matière dangereuse",maxPoints:3,source:"product",inputs:["hasHazardousMaterials"],measure:({hasHazardousMaterials:e})=>e===null?null:e?0:3}]},N={key:"demand",label:"Demande",maxPoints:20,criteria:[{key:"velocity",label:"Vélocité",maxPoints:7,source:"product",inputs:["monthlySales"],measure:({monthlySales:e})=>e===null?null:m(e,[[20,7],[10,4],[5,2]])},{key:"velocity_per_fba_seller",label:"Vélocité par vendeur FBA",maxPoints:5,source:"product",inputs:["monthlySales","fbaSellerCount"],measure:({monthlySales:e,fbaSellerCount:r})=>e===null||r===null?null:r===0?5:m(e/r,[[10,5],[5,3],[3,1]])},{key:"rank_and_trend",label:"Rang et tendance",maxPoints:4,source:"product",inputs:["bestSellerRank","averageSalesRank90"],measure:({bestSellerRank:e,averageSalesRank90:r})=>{if(e===null)return null;const n=r!==null&&e<r;return e<=5e4?n?4:3:e<=15e4?2:e<=3e5?1:0}},{key:"sales_trend",label:"Tendance des ventes",maxPoints:4,source:"product",inputs:["salesRankDrops30","salesRankDrops90"],measure:({salesRankDrops30:e,salesRankDrops90:r})=>{if(e===null||r===null)return null;const n=r/3;if(n===0)return e>0?4:0;const t=e/n;return t>=1.2?4:t>=.8?2:0}}]},T={key:"competition",label:"Concurrence",maxPoints:10,criteria:[{key:"competing_stock",label:"Stock en face",maxPoints:6,source:"product",inputs:["competingFbaStock"],measure:({competingFbaStock:e})=>e===null?null:e<=10?6:e<=30?4:e<=100?2:0},{key:"buy_box_and_sellers",label:"Buy Box et vendeurs",maxPoints:4,source:"product",inputs:["sellerCount","buyBoxSuppressed"],measure:({sellerCount:e,buyBoxSuppressed:r})=>e===null||r===null?null:e>=20?0:r?1:e<5?4:2}]},M={key:"dossier",label:"Conformité du dossier",maxPoints:8,criteria:[{key:"new_comparable_unit",label:"Neuf, unité comparable",maxPoints:2,source:"product",inputs:["packageQuantity","hasUsedBuyBox"],measure:({packageQuantity:e,hasUsedBuyBox:r})=>e===null||r===null?null:e===1&&!r?2:0},{key:"no_variations",label:"Sans variations",maxPoints:2,source:"product",inputs:["variationsCount"],measure:({variationsCount:e})=>e===null?null:e<=1?2:0},{key:"customer_rating",label:"Note client",maxPoints:1,source:"product",inputs:["rating","reviewsCount"],measure:({rating:e,reviewsCount:r})=>e===null||r===null?null:e>=4&&r>=20?1:0},{key:"price_stability",label:"Stabilité du prix",maxPoints:2,source:"product",inputs:["currentPrice","averagePrice90"],measure:({currentPrice:e,averagePrice90:r})=>{if(e===null||r===null||r<=0)return null;const n=Math.abs(e-r)/r;return n<=.1?2:n<=.2?1:0}},{key:"logistics",label:"Logistique",maxPoints:1,source:"product",inputs:["packageWeightGrams"],measure:({packageWeightGrams:e})=>e===null?null:e<=500?1:0}]},D=[I,v,N,T,M];function R(e,r){const n=e.measure(r),t=n===null;return{key:e.key,label:e.label,points:t?Math.floor(e.maxPoints/2):n,maxPoints:e.maxPoints,unmeasured:t}}function B(e,r){const n=e.criteria.map(t=>R(t,r));return{key:e.key,label:e.label,points:n.reduce((t,l)=>t+l.points,0),maxPoints:e.maxPoints,criteria:n}}function L(e){const r=Object.entries(e).map(([n,t])=>[n,t??null]);return Object.fromEntries(r)}class j{static calculate(r){const n=L(r),t=D.map(u=>B(u,n)),l=t.flatMap(u=>u.criteria.filter(s=>s.unmeasured));return l.reduce((u,s)=>u+s.maxPoints,0)>O*C?{status:"insufficient",missing:l.map(u=>u.label),families:t}:{status:"scored",points:t.reduce((u,s)=>u+s.points,0),families:t,unmeasured:l.length}}}function w({brand:e,observed:r,sellerNames:n,unresolvedSellerIds:t}){if(e===null||e.trim()===""||!r)return null;const l=e.toLowerCase(),i=new Set(t);return Object.entries(n).filter(([s])=>!i.has(s)).map(([,s])=>s).some(s=>s.toLowerCase().includes(l))?!0:i.size>0?null:!1}class U{static build({readings:r,netMarginPercent:n,netRoiPercent:t,rightToSell:l,sellers:i}){return{...r,netMarginPercent:n,netRoiPercent:t,rightToSell:l,brandIsSelling:w(i)}}}const g=10,z={sellerNames:{},unresolvedSellerIds:[]};function V(e,r){return{brand:e.brand,observed:e.sellersObserved&&r!==null,...r??z}}function $({measurements:e,sellerLookup:r,purchasePrice:n,sellingPrice:t,netMarginPercent:l,netRoiPercent:i,refreshHref:u}){const[s,d]=b.useState(!1),a={purchase:n===null,selling:t===null},p=!a.purchase&&!a.selling,f=r===void 0,o=b.useMemo(()=>
1{if(!p||e===null)return null;const P=U.build({readings:e.readings,netMarginPercent:l,netRoiPercent:i,rightToSell:null,sellers:V(e,r??null)});return j.calculate(P)},[p,e,r,l,i]);function y(){if(!p||o===null){_(x.PRODUCT_SCORE_BLOCKED_NO_PRICES,{missing_purchase_price:a.purchase,missing_selling_price:a.selling}),d(!0);return}_(x.PRODUCT_SCORE_OPENED,{outcome:o.status,score_band:o.status==="scored"?Math.floor(o.points/g)*g:null,unmeasured_count:o.status==="scored"?o.unmeasured:o.missing.length,right_to_sell_known:!1}),d(!0)}return c.jsxs(c.Fragment,{children:[c.jsx(A,{icon:E,label:"Voir le score d'arbitrage",disabled:f,disabledLabel:"Score disponible dès que les vendeurs sont résolus",onClick:f?void 0:y}),c.jsx(k,{open:s,onOpenChange:d,result:o,missingPrices:a,gatheredAt:e?.gatheredAt??{raw:null,formatted:"â"},refreshHref:u})]})}export{$ as ProductScoreAction};
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.