export type PhotoWorkflow = {number:number;name:string;defaultWorkflow:boolean;min:number;max:number;stationScope:string;positions:string[]}; export type PhotoSet = {number:number;name:string;defaultSet:boolean;workflows:PhotoWorkflow[]}; export type PhotoOptions = {configured:boolean;sets:PhotoSet[]}; export function photoFlows(set:PhotoSet|null,type:"PICKUP"|"DELIVERY"|"BOTH") { // Match PHP photoScopeMatches on stored tr_ware_from_to (PICKUP=2, DELIVERY=1). return (set?.workflows??[]).filter(f=>type==="BOTH" || f.stationScope==="ALL" || (["PICKUP_ONLY","EXCEPT_DELIVERY"].includes(f.stationScope)?type==="DELIVERY":type==="PICKUP")); } export function defaultPhoto(flows:PhotoWorkflow[],index:number,count:number) { const position=index===count-1?"LAST":index===0?"FIRST":"MIDDLE"; return flows.find(f=>f.positions.includes(position))??flows.find(f=>f.defaultWorkflow); } export const photoLabel=(f:PhotoWorkflow)=>`${f.name} · ${f.min===f.max?f.min:`${f.min}–${f.max}`} Fotos`;