1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="569f8e07-2ba3-4144-a8c4-31d23b9485f9",e._sentryDebugIdIdentifier="sentry-dbid-569f8e07-2ba3-4144-a8c4-31d23b9485f9")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2408],{13008:(e,t,r)=>{r.d(t,{b:()=>f});var a=r(24554),n=r(91394),i=r(98590),l=r(7424),s=r(61579),o=r(85999),c=r(25838);let d=async(e,t)=>(0,c.dd)((e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(e=>{let[r,a]=e;void 0!==a&&t.append(r,null===a?"null":String(a))});let r=t.toString();return r.length>0?"/api/v1/locations?".concat(r):"/api/v1/locations"})(e),{...t,method:"GET"}),u=e=>["/api/v1/locations",...e?[e]:[]],m=async(e,t)=>(0,c.dd)("/api/v1/locations",{...t,method:"POST",headers:{"Content-Type":"application/json",...null==t?void 0:t.headers},body:JSON.stringify(e)});var h=r(19860),p=r(7535);function f(e){let{value:t,onValueChange:r,locationType:c,defaultCreateType:f="warehouse",placeholder:g="Select location",searchPlaceholder:x="Type to search or createâ¦",disabled:y,className:I}=e,{data:j}=function(e,t,r){let a=((e,t)=>{var r;let{query:a,request:n}=null!=t?t:{};return{queryKey:null!=(r=null==a?void 0:a.queryKey)?r:u(e),queryFn:t=>{let{signal:r}=t;return d(e,{signal:r,...n})},...a}})(e,t);return{...(0,o.I)(a,void 0),queryKey:a.queryKey}}(c?{locationType:c,limit:100}:{limit:100},{query:{select:e=>{var t;return null!=(t=e.items)?t:[]}}}),v=function(){let e=(0,l.jE)(),[t]=u();return(0,s.n)({mutationFn:e=>m((0,h.E)(e)),onSuccess:()=>{e.invalidateQueries({predicate:e=>(0,p.D)(e.queryKey,t)})}})}(),C=(0,n.useMemo)(()=>(null!=j?j:[]).map(e=>({value:e.id,label:e.code?"".concat(e.name," (").concat(e.code,")"):e.name})),[j]);return(0,a.jsx)(i.$,{options:C,value:null!=t?t:void 0,onValueChange:r,placeholder:g,searchPlaceholder:x,disabled:y,className:I,entityLabel:"location",createMutation:v,formatNewEntity:e=>({name:e,locationType:f}),extractId:e=>e.id})}},15549:(e,t,r)=>{r.d(t,{S:()=>eg});var a=r(24554),n=r(93438),i=r(20214),l=r(11188),s=r(29522),o=r(34556),c=r(33001),d=r(68703),u=r(92074),m=r(44659),h=r(22512);let p=(0,d.r)(u.kkD).omit({id:!0,createdAt:!0,updatedAt:!0,deletedAt:!0,organizationId:!0,userId:!0,requestTimezone:!0}).extend({portOfLoadingId:m.Yj().nullable().optional().transform(e=>e||null),portOfDestinationId:m.Yj().nullable().optional().transform(e=>e||null),originLocationId:m.Yj().nullable().optional().transform(e=>e||null),destinationLocationId:m.Yj().nullable().optional().transform(e=>e||null),targetEtd:m.Yj().nullable().optional().transform(e=>e||null),targetWeek:m.Yj().nullable().optional().transform(e=>e||null),targetEta:m.Yj().nullable().optional().transform(e=>e||null),targetArrivalWeek:m.Yj().nullable().optional().transform(e=>e||null)});p.partial();let f=(0,d.r)(u.JNJ).omit({id:!0,createdAt:!0,updatedAt:!0,deletedAt:!0,organizationId:!0,requestId:!0}).extend({quantity:m.ai().int().min(1,"Quantity must be at least 1"),targetUnitPrice:h.jD,hsCode:m.Yj().nullable().optional().transform(e=>e||null),netWeightKg:h.jD,grossWeightKg:h.jD}),g=m.Ik({request:p,items:m.YO(f).min(1,"At least one unit type is required")});var x=r(30324),y=r(18420),I=r(91228),j=r(81110),v=r(15506),C=r(91394),b=r(12392),N=r(70428),T=r(66573),E=r(27262),O=r(37097),A=r(13565);function R(e){var t;let{groups:r,value:n,onValueChange:i,placeholder:l="Select option...",searchPlaceholder:s="Search...",emptyText:o="No option found.",className:c,disabled:d=!1,contentWidth:u}=e,[m,h]=C.useState(!1),p=C.useMemo(()=>r.flatMap(e=>e.options),[r]),f=n?null==(t=p.find(e=>e.value===n))?void 0:t.label:void 0;return(0,a.jsxs)(A.AM,{open:m,onOpenChange:h,modal:!1,children:[(0,a.jsx)(A.Wv,{asChild:!0,children:(0,a.jsxs)(E.$,{variant:"outline",role:"combobox","aria-expanded":m,className:(0,T.cn)("w-full justify-between bg-background font-normal",!n&&"text-muted-foreground",c),disabled:d,children:[(0,a.jsx)("span",{className:"truncate",children:null!=f?f:l}),(0,a.jsx)(b.m,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,a.jsx)(A.hl,{className:(0,T.cn)("p-0",u),side:"bottom",sideOffset:4,style:u?void 0:{width:"var(--radix-popover-trigger-width)"},onWheel:e=>e.stopPropagation(),children:(0,a.jsxs)(O.uB,{children:[(0,a.jsx)(O.G7,{placeholder:s}),(0,a.jsxs)(O.oI,{className:"max-h-[350px]",children:[(0,a.jsx)(O.xL,{children:o}),r.map(e=>(0,a.jsx)(O.L$,{heading:e.label,children:e.options.map(e=>(0,a.jsxs)(O.h_,{value:e.value,keywords:[e.label],onSelect:e=>{var t;let r=p.find(t=>t.value.toLowerCase()===e.toLowerCase()),a=(null==r?void 0:r.value)===n?null:null!=(t=null==r?void 0:r.value)?t:null;null==i||i(a),h(!1)},children:[(0,a.jsx)(N.S,{className:(0,T.cn)("mr-2 h-4 w-4",n===e.value?"opacity-100":"opacity-0")}),e.label]},e.value))},e.label))]})]})})]})}var q=r(60551),_=r(372),w=r(80610),S=r(74537),L=r(13008);function k(e){let{form:t,currentMode:r,fieldArray:i,isPostSendStatus:l}=e,{t:s}=(0,n.uU)(),{fields:o}=i;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I.zB,{control:t.control,name:"request.mode",render:e=>{var r;let{field:n}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{required:!0,children:s("commercial.freight.requests.transportMode")}),(0,a.jsx)(I.MJ,{children:(0,a.jsxs)(v.l6,{value:null!=(r=n.value)?r:"ocean",onValueChange:e=>{var r;if(!(0,x.Z)(e,w.S_))return;n.onChange(e);let a=null==(r=(0,w.eM)(e)[0])?void 0:r.types[0];o.length>0&&a&&o.forEach((e,r)=>{t.setValue("items.".concat(r,".unitType"),a)})},disabled:l,children:[(0,a.jsx)(v.bq,{children:(0,a.jsx)(v.yv,{placeholder:s("c
1ommercial.freight.requests.selectTransportMode")})}),(0,a.jsx)(v.gC,{children:w.S_.map(e=>(0,a.jsx)(v.eb,{value:e,children:w.qG[e]},e))})]})}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-4",children:"land"===r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I.zB,{control:t.control,name:"request.originLocationId",render:e=>{let{field:t}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:s("commercial.freight.requests.originLabel")}),(0,a.jsx)(I.MJ,{children:(0,a.jsx)(L.b,{value:t.value,onValueChange:t.onChange,placeholder:s("commercial.freight.requests.selectOrigin"),disabled:l})}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsx)(I.zB,{control:t.control,name:"request.destinationLocationId",render:e=>{let{field:t}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:s("commercial.freight.requests.destinationLabel")}),(0,a.jsx)(I.MJ,{children:(0,a.jsx)(L.b,{value:t.value,onValueChange:t.onChange,placeholder:s("commercial.freight.requests.selectDestination"),disabled:l})}),(0,a.jsx)(I.C5,{})]})}})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I.zB,{control:t.control,name:"request.portOfLoadingId",render:e=>{var t;let{field:n}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:"air"===r?s("commercial.freight.requests.originAirport"):s("commercial.freight.requests.portOfLoading")}),(0,a.jsx)("div",{children:(0,a.jsx)(I.MJ,{children:(0,a.jsx)(S.vX,{value:null!=(t=n.value)?t:void 0,onValueChange:n.onChange,placeholder:"air"===r?s("commercial.freight.requests.selectOriginAirport"):s("commercial.freight.requests.selectPortLoading"),locationType:"air"===r?"airport":"seaport",disabled:l})})}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsx)(I.zB,{control:t.control,name:"request.portOfDestinationId",render:e=>{var t;let{field:n}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:"air"===r?s("commercial.freight.requests.destinationAirport"):s("commercial.freight.requests.portOfDestination")}),(0,a.jsx)("div",{children:(0,a.jsx)(I.MJ,{children:(0,a.jsx)(S.vX,{value:null!=(t=n.value)?t:void 0,onValueChange:n.onChange,placeholder:"air"===r?s("commercial.freight.requests.selectDestinationAirport"):s("commercial.freight.requests.selectPortDestination"),locationType:"air"===r?"airport":"seaport",disabled:l})})}),(0,a.jsx)(I.C5,{})]})}})]})})]})}var F=r(1779),P=r(77515),D=r(74124),M=r(59485),W=r(51531),B=r(90775);function U(e){let{mode:t,isPostSendStatus:r,linkedDocsQuery:i,detachMutation:l,fileInputRef:s,handleFileSelect:o,triggerUpload:c,isUploading:d,acceptString:u,pendingFiles:m,pendingFileInputRef:h,handlePendingFileSelect:p,removePendingFile:f}=e,{t:g}=(0,n.uU)();return r?null:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(I.lR,{children:g("commercial.freight.requests.attachedDocuments")}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:g("commercial.freight.requests.docsWillBeIncluded")}),"edit"===t&&i.data&&i.data.length>0&&(0,a.jsx)("div",{className:"space-y-1",children:i.data.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:[(0,a.jsx)(F.A,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate flex-1",children:e.document.fileName}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:e.document.fileSize?"".concat((e.document.fileSize/1024).toFixed(0),"KB"):""}),(0,a.jsx)(E.$,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 shrink-0",disabled:l.isPending,onClick:()=>l.mutate({linkId:e.link.id},{onSuccess:()=>{i.refetch()},onError:e=>(0,B.Ox)(e,"Detach document")}),children:(0,a.jsx)(P.u,{className:"h-3 w-3"})})]},e.link.id))}),"create"===t&&m.length>0&&(0,a.jsx)("div",{className:"space-y-1",children:m.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:[(0,a.jsx)(F.A,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate flex-1",children:e.name}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:"".concat((e.size/1024).toFixed(0),"KB")}),(0,a.jsx)(E.$,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 shrink-0",onClick:()=>f(t),children:(0,a.jsx)(P.u,{className:"h-3 w-3"})})]},"".concat(e.name,"-").concat(t)))}),"edit"===t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{ref:s,t
1ype:"file",multiple:!0,accept:u,className:"hidden",onChange:o}),(0,a.jsx)(E.$,{type:"button",variant:"outline",size:"sm",disabled:d,onClick:c,children:d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(D.N,{className:"h-4 w-4 mr-2 animate-spin"}),g("commercial.freight.requests.uploading")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(M.J,{className:"h-4 w-4 mr-2"}),g("commercial.freight.requests.attachFiles")]})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{ref:h,type:"file",multiple:!0,accept:W.$G,className:"hidden",onChange:p}),(0,a.jsxs)(E.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{var e;return null==(e=h.current)?void 0:e.click()},children:[(0,a.jsx)(M.J,{className:"h-4 w-4 mr-2"}),g("commercial.freight.requests.attachFiles")]})]})]})}var K=r(69796),V=r(26418),G=r(45766),z=r(47625),H=r(66843),Y=r(99032),J=r(48136),$=r(62773),Q=r(17006),Z=r(77215),X=r(23808),ee=r(5182),et=r(87755),er=r(71079),ea=r(85388);function en(e){let{value:t,onWeekSelect:r,className:n}=e,i=function(e){if(!e)return;let t=e.match(/^(\d{4})-W(\d{2})$/);if(!t)return;let r=parseInt(t[1],10),a=parseInt(t[2],10),n=new Date(r,0,4),i=(0,z.b)(n);return(0,H.f)(i,(a-1)*7)}(t),l=null!=t?t:"",[s,o]=C.useState(()=>null!=i?i:new Date),c=function(e){let t=(0,z.b)((0,Y.w)(e)),r=(0,J.g)((0,$.p)(e)),a=[],n=t;for(;n<=r;){let e=[];for(let t=0;t<7;t++)e.push((0,H.f)(n,t));a.push({weekNumber:(0,Q.s)(n),weekYear:(0,Z.p)(n),days:e}),n=(0,H.f)(n,7)}return a}(s);return(0,a.jsxs)("div",{className:(0,T.cn)("p-3",n),children:[(0,a.jsxs)("div",{className:"flex justify-center pt-1 relative items-center mb-4",children:[(0,a.jsx)("button",{type:"button",onClick:()=>o(e=>(0,X.a)(e,1)),className:(0,T.cn)((0,E.r)({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute left-1"),children:(0,a.jsx)(V.e,{className:"h-4 w-4"})}),(0,a.jsx)("span",{className:"text-sm font-medium",children:(0,ee.GP)(s,"MMMM yyyy")}),(0,a.jsx)("button",{type:"button",onClick:()=>o(e=>(0,et.P)(e,1)),className:(0,T.cn)((0,E.r)({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute right-1"),children:(0,a.jsx)(G.J,{className:"h-4 w-4"})})]}),(0,a.jsxs)("table",{className:"w-full border-collapse",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"flex",children:[(0,a.jsx)("th",{className:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem] text-center",children:"Wk"}),["Mo","Tu","We","Th","Fr","Sa","Su"].map(e=>(0,a.jsx)("th",{className:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem] text-center",children:e},e))]})}),(0,a.jsx)("tbody",{children:c.map(e=>{let t,n,i=(t=e.weekYear,n=e.weekNumber,l==="".concat(t,"-W").concat(String(n).padStart(2,"0")));return(0,a.jsxs)("tr",{onClick:()=>((e,t)=>{let a="".concat(e,"-W").concat(String(t).padStart(2,"0"));null==r||r(a)})(e.weekYear,e.weekNumber),className:(0,T.cn)("flex w-full mt-1 cursor-pointer rounded-md transition-colors",i?"bg-primary":"hover:bg-accent"),children:[(0,a.jsx)("td",{className:(0,T.cn)("h-9 w-9 flex items-center justify-center text-[0.8rem] font-normal rounded-l-md",i?"text-primary-foreground":"text-muted-foreground"),children:e.weekNumber}),e.days.map((e,t)=>(0,a.jsx)("td",{className:(0,T.cn)("h-9 w-9 flex items-center justify-center text-sm font-normal",6===t&&"rounded-r-md",i?"text-primary-foreground":(0,er.t)(e,s)?(0,ea.c)(e)?"bg-accent text-accent-foreground rounded-md":"text-foreground":"text-muted-foreground"),children:(0,ee.GP)(e,"d")},e.toISOString()))]},"".concat(e.weekYear,"-").concat(e.weekNumber))})})]})]})}en.displayName="WeekPicker";var ei=r(94247),el=r(90720),es=r(43735),eo=r(92650),ec=r(51640),ed=r(18173),eu=r(37131),em=r(24349),eh=r(86022);function ep(e){var t,r;let{mode:i,initialData:l,onSubmit:d,onCancel:u,isPending:m=!1,secondaryAction:h,ordersForFreight:p,initialOrderId:f}=e,{t:b}=(0,n.uU)(),N=e=>{if(e)try{return(0,eu.Fd)(e)}catch(e){return}},O="edit"===i&&l&&"id"in l?l.id:void 0,[S,L]=(0,C.useState)([]),F=(0,C.useRef)(null),P=(0,C.useCallback)(e=>{let t=e.target.files;t&&0!==t.length&&(L(e=>[...e,...Array.from(t)]),e.target.value="")},[]),D=(0,C.useCallback)(e=>{L(t=>t.filter((t,r)=>r!==e))},[]),{isUploading:M,fileInputRef:W,handleFileSelect:B,triggerUpload:V,acceptString:G}=(0,em.v)({entityType:"request",requestId:null!=O?O:"",onSuccess:()=>{O&&z.refetch()}}),z=(0,ed.g1)(O||null),H=(0,ed.PD)(),Y=(0,ec.a)(),J={unitType:"20ft DC",quantity:1,targetUnitPrice:void 0,hsCode:null,netWeightKg:void 0,grossWeightKg:void 0},$=(0,s.mN)({resolver:(0,c.u)(g),defaultValues:(()=>
1{if(l){var e,t,r,a,n,s,o,c,d,u;let m="items"in l&&Array.isArray(l.items)?l.items.map(e=>{var t;return{unitType:e.unitType,quantity:e.quantity,targetUnitPrice:null!==e.targetUnitPrice&&void 0!==e.targetUnitPrice?String(e.targetUnitPrice):void 0,hsCode:null!=(t="hsCode"in e?e.hsCode:void 0)?t:null,netWeightKg:"netWeightKg"in e&&null!==e.netWeightKg&&void 0!==e.netWeightKg?String(e.netWeightKg):void 0,grossWeightKg:"grossWeightKg"in e&&null!==e.grossWeightKg&&void 0!==e.grossWeightKg?String(e.grossWeightKg):void 0}}):[J];return{request:{reference:"edit"===i&&null!=(e=l.reference)?e:"",mode:null!=(t="mode"in l?l.mode:void 0)?t:"ocean",portOfLoadingId:null!=(r=l.portOfLoadingId)?r:null,portOfDestinationId:null!=(a=l.portOfDestinationId)?a:null,originLocationId:null!=(n="originLocationId"in l?l.originLocationId:null)?n:null,destinationLocationId:null!=(s="destinationLocationId"in l?l.destinationLocationId:null)?s:null,targetEtd:null!=(o=l.targetEtd)?o:null,targetWeek:null!=(c=l.targetWeek)?c:null,targetEta:null!=(d="targetEta"in l?l.targetEta:null)?d:null,targetArrivalWeek:null!=(u="targetArrivalWeek"in l?l.targetArrivalWeek:null)?u:null,status:"edit"===i&&(0,x.Z)(l.status,w.$A)?l.status:"draft",targetPriceCurrency:(()=>{let e="targetPriceCurrency"in l?l.targetPriceCurrency:void 0;return(0,x.Z)(e,y.S2)?e:y.OS})()},items:m.length>0?m:[J]}}return{request:{reference:"",mode:"ocean",portOfLoadingId:null,portOfDestinationId:null,originLocationId:null,destinationLocationId:null,targetEtd:null,targetWeek:null,targetEta:null,targetArrivalWeek:null,status:"draft",targetPriceCurrency:y.OS},items:[J]}})()}),Q=(0,s.jz)({control:$.control,name:"items"}),{fields:Z,append:X,remove:et}=Q,{data:er}=(0,ed.vm)("create"===i);(0,C.useEffect)(()=>{"create"===i&&er&&!$.getValues("request.reference")&&$.setValue("request.reference",er)},[er,i,$]);let[ea,ep]=(0,C.useState)(null!=f?f:null);(0,C.useEffect)(()=>{void 0!==f&&ep(f)},[f]);let ef=(0,C.useMemo)(()=>(null!=p?p:[]).map(e=>{var t,r;return{value:e.id,label:[e.orderNumber||"Untitled","purchase_order"===e.type?"PO":"SO","purchase_order"===e.type?null==(t=e.seller)?void 0:t.name:null==(r=e.buyer)?void 0:r.name].filter(Boolean).join(" \xb7 ")}}),[p]),eg=(0,C.useCallback)(e=>{if(ep(e),e&&p){let t=p.find(t=>t.id===e);t&&(t.portOfLoadingId&&$.setValue("request.portOfLoadingId",t.portOfLoadingId),t.portOfDestinationId&&$.setValue("request.portOfDestinationId",t.portOfDestinationId),(0,x.Z)(t.currency,y.S2)&&$.setValue("request.targetPriceCurrency",t.currency))}},[p,$]);(0,C.useEffect)(()=>{if(null!=f&&(ep(f),"create"===i&&p)){let e=p.find(e=>e.id===f);e&&(e.portOfLoadingId&&$.setValue("request.portOfLoadingId",e.portOfLoadingId),e.portOfDestinationId&&$.setValue("request.portOfDestinationId",e.portOfDestinationId),(0,x.Z)(e.currency,y.S2)&&$.setValue("request.targetPriceCurrency",e.currency))}},[f,i]),(0,C.useEffect)(()=>{if("create"!==i||!ea||!p)return;let e=$.getValues("request.portOfLoadingId"),t=$.getValues("request.portOfDestinationId"),r=$.getValues("request.targetPriceCurrency");if(e&&t&&r!==y.OS)return;let a=p.find(e=>e.id===ea);a&&(a.portOfLoadingId&&!e&&$.setValue("request.portOfLoadingId",a.portOfLoadingId),a.portOfDestinationId&&!t&&$.setValue("request.portOfDestinationId",a.portOfDestinationId),(0,x.Z)(a.currency,y.S2)&&r===y.OS&&$.setValue("request.targetPriceCurrency",a.currency))},[p]);let ex=e=>{$.setValue("request.targetEtd",e?(0,ee.GP)(e,"yyyy-MM-dd"):null),e&&$.setValue("request.targetWeek",null)},ey=e=>{$.setValue("request.targetWeek",e),$.setValue("request.targetEtd",null)},eI=e=>{$.setValue("request.targetEta",e?(0,ee.GP)(e,"yyyy-MM-dd"):null),e&&$.setValue("request.targetArrivalWeek",null)},ej=e=>{$.setValue("request.targetArrivalWeek",e),$.setValue("request.targetEta",null)},ev=e=>{if(!e)return;let t=e.match(/^(\d{4})-W(\d{2})$/);if(t)return"Week ".concat(parseInt(t[2],10),", ").concat(t[1])},eC=null!=(t=$.watch("request.mode"))?t:"ocean",eb=e=>{let t=Z.map((t,r)=>r!==e?t.unitType:null).filter(e=>null!==e);return(0,w.eM)(eC).flatMap(e=>e.types).filter(e=>!t.includes(e))},eN=e=>{let t=eb(e);return(0,w.eM)(eC).map(e=>({label:e.label,options:e.types.filter(e=>t.includes(e)).map(e=>({value:e,label:w.ad[e]}))})).filter(e=>e.options.length>0)}
1,eT=null!=(r=$.watch("request.status"))?r:"draft",eE="edit"===i&&["sent","quoted","closed"].includes(eT);return(0,a.jsxs)(_.w,{form:$,onSubmit:e=>d(e,"create"===i?S:void 0,ea),onCancel:u,mode:i,isPending:m,secondaryAction:eE?void 0:h,children:[eE&&"edit"===i&&(0,a.jsxs)(o.Fc,{className:"bg-muted/50 border-muted-foreground/20",children:[(0,a.jsx)(ei.X,{className:"h-4 w-4"}),(0,a.jsx)(o.TN,{className:"text-sm",children:b("commercial.freight.requests.lockedBanner")})]}),(0,a.jsx)(I.zB,{control:$.control,name:"request.reference",render:e=>{let{field:t}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{required:!0,children:b("commercial.freight.requests.referenceLabel")}),(0,a.jsx)(I.MJ,{children:(0,a.jsx)(j.p,{...t,disabled:eE,"data-testid":"create"===i?"input-reference":"input-edit-reference"})}),(0,a.jsx)(I.C5,{})]})}}),ef.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.sourceOrder")}),(0,a.jsx)(q.G,{options:ef,value:null!=ea?ea:"",onValueChange:e=>eg(e||null),placeholder:b("commercial.freight.requests.linkToPo"),searchPlaceholder:b("commercial.freight.requests.searchOrders"),emptyText:b("commercial.freight.requests.noOrders"),disabled:eE}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:b("commercial.freight.requests.sourceOrderHint")})]}),(0,a.jsx)(k,{form:$,currentMode:eC,fieldArray:Q,isPostSendStatus:eE}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsx)(I.zB,{control:$.control,name:"request.targetEtd",render:e=>{let{field:t}=e;return(0,a.jsxs)(I.eI,{className:"flex flex-col",children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.targetEtd")}),(0,a.jsx)("div",{children:(0,a.jsxs)(A.AM,{children:[(0,a.jsx)(A.Wv,{asChild:!0,children:(0,a.jsx)(I.MJ,{children:(0,a.jsxs)(E.$,{variant:"outline",disabled:eE,className:(0,T.cn)("w-full justify-start text-left font-normal",!t.value&&"text-muted-foreground"),"data-testid":"create"===i?"button-target-etd":"button-edit-target-etd",children:[(0,a.jsx)(el.C,{className:"mr-2 h-4 w-4"}),t.value?(0,ee.GP)((0,eu.Fd)(t.value),"PPP"):(0,a.jsx)("span",{children:b("commercial.freight.requests.pickDate")})]})})}),(0,a.jsx)(A.hl,{className:"w-auto p-0",align:"start",children:(0,a.jsx)(K.V,{mode:"single",selected:N(t.value),onSelect:ex,initialFocus:!0})})]})}),(0,a.jsx)(I.Rr,{className:"text-xs",children:b("commercial.freight.requests.etdClearsWeek")}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsx)(I.zB,{control:$.control,name:"request.targetWeek",render:e=>{var t;let{field:r}=e;return(0,a.jsxs)(I.eI,{className:"flex flex-col",children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.targetDepartureWeek")}),(0,a.jsx)("div",{children:(0,a.jsxs)(A.AM,{children:[(0,a.jsx)(A.Wv,{asChild:!0,children:(0,a.jsx)(I.MJ,{children:(0,a.jsxs)(E.$,{variant:"outline",disabled:eE,className:(0,T.cn)("w-full justify-start text-left font-normal",!r.value&&"text-muted-foreground"),"data-testid":"create"===i?"button-target-week":"button-edit-target-week",children:[(0,a.jsx)(el.C,{className:"mr-2 h-4 w-4"}),r.value?ev(r.value):(0,a.jsx)("span",{children:b("commercial.freight.requests.pickWeek")})]})})}),(0,a.jsx)(A.hl,{className:"w-auto p-0",align:"start",children:(0,a.jsx)(en,{value:null!=(t=r.value)?t:void 0,onWeekSelect:ey})})]})}),(0,a.jsx)(I.Rr,{className:"text-xs",children:b("commercial.freight.requests.weekClearsEtd")}),(0,a.jsx)(I.C5,{})]})}})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsx)(I.zB,{control:$.control,name:"request.targetEta",render:e=>{let{field:t}=e;return(0,a.jsxs)(I.eI,{className:"flex flex-col",children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.targetEta")}),(0,a.jsxs)(A.AM,{children:[(0,a.jsx)(A.Wv,{asChild:!0,children:(0,a.jsx)(I.MJ,{children:(0,a.jsxs)(E.$,{variant:"outline",disabled:eE,className:(0,T.cn)("w-full justify-start text-left font-normal",!t.value&&"text-muted-foreground"),"data-testid":"create"===i?"button-target-eta":"button-edit-target-eta",children:[(0,a.jsx)(el.C,{className:"mr-2 h-4 w-4"}),t.value?(0,ee.GP)((0,eu.Fd)(t.value),"PPP"):(0,a.jsx)("span",{children:b("commercial.freight.requests.pickDate")})]})})}),(0,a.jsx)(A.hl,{className:"w-auto p-0",align:"start",children:(0,a.jsx)(K.V,{mode:"single",selected:N(t.value),onSelect:eI,initialFocus:!0})})]}),(0,a.jsx)(I.Rr,{className:"text-xs",children:b("commercial.freight.requests.etaClearsArrivalWeek")}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsx)(I.zB,{control:$.control,name:"request.targetArrivalWeek",render:e=>{var t;let{field:r}=e;return(0,a.jsxs)(I.eI,{className:"flex flex-col",children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.targetArrivalWeek")}),(0,a.jsxs)(A.AM,{children:[(0,a.jsx)(A.Wv,{asChild:!0,children:(0,a.jsx)(I.MJ,{children:(0,a.jsxs)(E.$,{variant:"outline",disabled:eE,className:(0,T.cn)("w-full justify-start text-left font-normal",!r.value&&"text-muted-foreground"),"data-testid":"create"===i?"button-target-arrival-week":"button-edit-target-arrival-week",children:[(0,a.jsx)(el.C,{className:"mr-2 h-4 w-4"}),r.value?ev(r.value):(0,a.jsx)("span",{children:b("commercial.freight.requests.pickWeek")})]})})}),(0,a.jsx)(A.hl,{className:"w-auto p-0",align:"start",children:(0,a.jsx)(en,{value:null!=(t=r.value)?t:void 0,onWeekSelect:ej})})]}),(0,a.jsx)(I.Rr,{className:"text-xs",children:b("commercial.freight.requests.weekClearsEta")}),(0,a.jsx)(I.C5,{})]})}})]}),(0,a.jsx)(I.zB,{control:$.control,name:"request.targetPriceCurrency",render:e=>{var t;let{field:r}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.currency")}),(0,a.jsxs)(v.l6,{onValueChange:r.onChange,value:null!=(t=r.value)?t:y.OS,disabled:eE,children:[(0,a.jsx)(I.MJ,{children:(0,a.jsx)(v.bq,{"data-testid":"create"===i?"
1select-currency":"select-edit-currency",children:(0,a.jsx)(v.yv,{placeholder:b("commercial.freight.requests.selectCurrency")})})}),(0,a.jsx)(v.gC,{children:y.S2.map(e=>(0,a.jsx)(v.eb,{value:e,children:y.Mx[e]},e))})]}),(0,a.jsx)(I.Rr,{className:"text-xs",children:b("commercial.freight.requests.currencyHint")}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(I.lR,{required:!0,children:b("commercial.freight.requests.containerRequirements")}),(0,a.jsx)("div",{children:Y?(0,a.jsx)("div",{className:"space-y-3",children:Z.map((e,t)=>(0,a.jsxs)("div",{className:"rounded-lg border bg-card p-4 space-y-3","data-testid":"container-row-mobile-".concat(t),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:b("commercial.freight.requests.containerMobile",{index:String(t+1)})}),(0,a.jsx)(E.$,{type:"button",variant:"ghost",size:"sm",disabled:eE||1===Z.length,onClick:()=>et(t),"aria-label":b("commercial.freight.requests.removeContainer"),children:(0,a.jsx)(es.u,{className:"h-4 w-4"})})]}),(0,a.jsx)(I.zB,{control:$.control,name:"items.".concat(t,".unitType"),render:e=>{let{field:r}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.containerType")}),(0,a.jsx)(I.MJ,{children:(0,a.jsx)(R,{groups:eN(t),value:r.value,onValueChange:e=>r.onChange(null!=e?e:r.value),placeholder:b("commercial.freight.requests.selectContainer"),searchPlaceholder:b("commercial.freight.requests.searchContainers"),emptyText:b("commercial.freight.requests.noContainerType"),disabled:eE||1===eb(t).length,contentWidth:"w-[280px]"})}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsx)(I.zB,{control:$.control,name:"items.".concat(t,".quantity"),render:e=>{let{field:t}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.quantity")}),(0,a.jsx)(I.MJ,{children:(0,a.jsx)(j.p,{disabled:eE,type:"number",min:1,value:0===t.value?"":t.value,onChange:e=>{let r=e.target.value;t.onChange(""===r?0:parseInt(r,10)||0)},onBlur:()=>{var e;(null!=(e=t.value)?e:0)<1&&t.onChange(1)}})}),(0,a.jsx)(I.C5,{})]})}}),(0,a.jsx)(I.zB,{control:$.control,name:"items.".concat(t,".targetUnitPrice"),render:e=>{var t;let{field:r}=e;return(0,a.jsxs)(I.eI,{children:[(0,a.jsx)(I.lR,{children:b("commercial.freight.requests.targetPrice")}),(0,a.jsx)(I.MJ,{children:(0,a.jsx)(j.p,{disabled:eE,type:"number",step:"0.01",value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(e.target.value||void 0),placeholder:b("commercial.freight.requests.targetPrice")})}),(0,a.jsx)(I.C5,{})]})}})]})]},e.id))}):(0,a.jsxs)(eh.XI,{children:[(0,a.jsx)(eh.A0,{children:(0,a.jsxs)(eh.Hj,{children:[(0,a.jsx)(eh.nd,{children:b("commercial.freight.requests.colContainerType")}),(0,a.jsx)(eh.nd,{children:b("commercial.freight.requests.colQuantity")}),(0,a.jsx)(eh.nd,{children:b("commercial.freight.requests.colTargetPrice")}),(0,a.jsx)(eh.nd,{className:"w-[50px]"})]})}),(0,a.jsx)(eh.BF,{children:Z.map((e,t)=>(0,a.jsxs)(eh.Hj,{children:[(0,a.jsx)(eh.nA,{children:(0,a.jsx)(I.zB,{control:$.control,name:"items.".concat(t,".unitType"),render:e=>{let{field:r}=e;return(0,a.jsx)(R,{groups:eN(t),value:r.value,onValueChange:e=>r.onChange(null!=e?e:r.value),placeholder:b("commercial.freight.requests.selectContainer"),searchPlaceholder:b("commercial.freight.requests.searchContainers"),emptyText:b("commercial.freight.requests.noContainerType"),disabled:eE||1===eb(t).length,contentWidth:"w-[280px]"})}})}),(0,a.jsx)(eh.nA,{children:(0,a.jsx)(I.zB,{control:$.control,name:"items.".concat(t,".quantity"),render:e=>{let{field:t}=e;return(0,a.jsx)(j.p,{disabled:eE,type:"number",min:1,value:0===t.value?"":t.value,onChange:e=>{let r=e.target.value;t.onChange(""===r?0:parseInt(r,10)||0)},onBlur:()=>{var e;(null!=(e=t.value)?e:0)<1&&t.onChange(1)}})}})}),(0,a.jsx)(eh.nA,{children:(0,a.jsx)(I.zB,{control:$.control,name:"items.".concat(t,".targetUnitPrice"),render:e=>{var t;let{field:r}=e;return(0,a.jsx)(j.p,{disabled:eE,type:"number",step:"0.01",value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(e.target.value||void 0),placeholder:b("commercial.freight.requests.targetPriceOptional")})}})}),(0,a.jsx)(eh.nA,{children:(0,a.jsx)(E.$,{type:"button",variant:"ghost",size:"sm",disabled:eE||1===Z.length,onClick:()=>et(t),children:(0,a.jsx)(es.u,{className:"h-4 w-4"})})})]},e.id))})]})}),(0,a.jsxs)(E.$,{type:"button",variant:"outline",size:"sm",disabled:eE||Z.length>=(0,w.eM)(eC).flatMap(e=>e.types).length,onClick:()=>{var e;let t=(0,w.eM)(eC).flatMap(e=>e.types),r=Z.map(e=>e.unitType),a=null!=(e=t.filter(e=>!r.includes(e))[0])?e:t[0];
1a&&X({unitType:a,quantity:1,targetUnitPrice:void 0,hsCode:null,netWeightKg:void 0,grossWeightKg:void 0})},children:[(0,a.jsx)(eo.c,{className:"h-4 w-4 mr-2"}),b("commercial.freight.requests.addContainer")]})]}),(0,a.jsx)(U,{mode:i,isPostSendStatus:eE,linkedDocsQuery:z,detachMutation:H,fileInputRef:W,handleFileSelect:B,triggerUpload:V,isUploading:M,acceptString:G,pendingFiles:S,pendingFileInputRef:F,handlePendingFileSelect:P,removePendingFile:D})]})}var ef=r(618);function eg(e){var t;let{mode:r,open:s,onOpenChange:o,onSubmit:c,requestId:d,copyData:u,initialOrderId:m,isPending:h=!1,secondaryAction:p}=e,{t:f}=(0,n.uU)(),{data:g,isLoading:x,error:y}=(0,ed.CI)(d||"",!!d),{data:I}=(0,ef.Ls)(),{data:j}=(0,ed.Bt)("edit"===r&&null!=d?d:null),v=async(e,t,r)=>{c(e,t,r)};return(0,a.jsx)(i.r,{open:s,onOpenChange:o,title:f("edit"===r?g&&["sent","quoted","closed"].includes(g.status)?"commercial.freight.requests.sheetViewTitle":"commercial.freight.requests.sheetEditTitle":"commercial.freight.requests.sheetCreateTitle"),complexity:"complex",children:(0,a.jsx)(l.Z,{isLoading:"edit"===r&&x,error:"edit"===r?y:null,entityLabel:f("commercial.freight.requests.entityLabel"),onClose:()=>o(!1),children:(0,a.jsx)(ep,{mode:r,initialData:"edit"===r?g:u,onSubmit:v,onCancel:()=>o(!1),isPending:h,secondaryAction:p,ordersForFreight:null!=I?I:void 0,initialOrderId:"edit"===r?null!=(t=null==j?void 0:j.orderId)?t:null:null!=m?m:null})})})}},24349:(e,t,r)=>{r.d(t,{v:()=>d});var a=r(91394),n=r(9521),i=r(63487),l=r(90775),s=r(35976),o=r(15282),c=r(51531);function d(e){let[t,r]=(0,a.useState)(!1),d=(0,a.useRef)(null),u=i.i.useUtils(),m=(0,o.rn)(),{trackEntityCreated:h}=(0,s.s)(),p=(0,a.useCallback)(async t=>{let a=t.target.files;if(!a||0===a.length)return;let i=Array.from(a),s="shipment"===e.entityType?[i[0]]:i;for(let e of s){if(!c._5.includes(e.type)){n.oR.error("Invalid file type",{description:"".concat(e.name,": Please upload PDF, Word, Excel, CSV, or image files")}),d.current&&(d.current.value="");return}if(e.size>0x1400000){n.oR.error("File too large",{description:"".concat(e.name,": Maximum file size is 20MB")}),d.current&&(d.current.value="");return}}let o=crypto.randomUUID();r(!0);try{var p,f,g,x,y;let t=new FormData;if("shipment"===e.entityType)t.append("files",s[0]),t.append("shipmentId",e.shipmentId),t.append("documents",JSON.stringify([{documentType:e.documentType}]));else{for(let e of s)t.append("files",e);t.append("requestId",e.requestId)}let r=await fetch("/api/v1/documents/upload",{method:"POST",body:t,credentials:"include",headers:{"X-Idempotency-Key":o}});if(!r.ok){let e=await r.json();throw Error(e.error||e.message||"Failed to upload document")}let a=await r.json();if("shipment"===e.entityType){let t=a.documents||[],r=a.failedUploads||[];u.documents.getSummaryForShipment.invalidate({shipmentId:e.shipmentId}),u.documents.getVersionHistory.invalidate({shipmentId:e.shipmentId}),u.documents.listInfinite.invalidate(),m(),u.documents.getStatusCounts.invalidate(),u.documents.getProcessingCount.invalidate(),t.length>0&&h("document",{document_count:t.length,source:"inline_upload",document_type:e.documentType}),r.length>0?n.oR.error("Upload failed",{description:null!=(f=null==(p=r[0])?void 0:p.error)?f:"".concat(s[0].name," could not be uploaded")}):(n.oR.success("Document uploaded",{description:"".concat(s[0].name," uploaded successfully")}),null==(g=e.onSuccess)||g.call(e))}else{let t=a.documents||[];u.documents.listInfinite.invalidate(),m(),u.documents.getStatusCounts.invalidate(),u.documents.getProcessingCount.invalidate(),u.freightRequests.getDocumentsForRequest.invalidate({requestId:e.requestId}),h("document",{document_count:t.length,source:"request_upload"});let r=t.length;t.some(e=>e.linkingFailed)?n.oR.warning(1===r?"Document uploaded":"".concat(r," documents uploaded"),{description:"Uploaded successfully but failed to attach to this request. The document is available in the Documents page."}):n.oR.success(1===r?"Document uploaded":"".concat(r," documents uploaded"),{description:1===r?"".concat(null==(y=t[0])?void 0:y.fileName," attached to request"):"".concat(r," files attached to request")}),null==(x=e.onSuccess)||x.call(e)}}catch(e){(0,l.Ox)(e,"Upload document")}finally{r(!1),d.current&&(d.current.value="")}},[e,u,h,m]),f=(0,a.useCallback)(()=>{var e;
1null==(e=d.current)||e.click()},[]);return{isUploading:t,fileInputRef:d,handleFileSelect:p,triggerUpload:f,acceptString:c.sl}}},35976:(e,t,r)=>{r.d(t,{s:()=>l});var a=r(4417),n=r(91394),i=r(34276);function l(){let e=(0,a.sf)(),t=(0,n.useCallback)((t,r)=>{if(!e)return void i.v.debug("[Analytics] PostHog not available, skipping: ".concat(t));try{e.capture(t,r)}catch(e){i.v.error("[Analytics] Failed to track event: ".concat(t),{error:e,properties:r})}},[e]),r=(0,n.useCallback)((e,r)=>{t("".concat(e,"_created"),r)},[t]),l=(0,n.useCallback)((e,r)=>{t("".concat(e,"_updated"),r)},[t]),s=(0,n.useCallback)(e=>{t("chat_conversation",{...e})},[t]),o=(0,n.useCallback)(e=>{t("chat_file_uploaded",{...e})},[t]),c=(0,n.useCallback)(e=>{t("onboarding_step",{...e})},[t]);return{track:t,trackEntityCreated:r,trackEntityUpdated:l,trackChatConversation:s,trackFileUpload:o,trackOnboardingStep:c}}},53875:(e,t,r)=>{r.d(t,{Hr:()=>f,Ht:()=>v,I:()=>m,M5:()=>x,SQ:()=>y,_2:()=>I,dc:()=>h,hO:()=>j,lp:()=>C,lv:()=>p,mB:()=>b,nV:()=>g,rI:()=>d,ty:()=>u});var a=r(24554),n=r(91394),i=r(79821),l=r(45766),s=r(70428),o=r(60618),c=r(66573);let d=i.bL,u=i.l9,m=i.YJ,h=i.ZL,p=i.Pb,f=i.z6,g=n.forwardRef((e,t)=>{let{className:r,inset:n,children:s,...o}=e;return(0,a.jsxs)(i.ZP,{ref:t,className:(0,c.cn)("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n&&"pl-8",r),...o,children:[s,(0,a.jsx)(l.J,{className:"ml-auto"})]})});g.displayName=i.ZP.displayName;let x=n.forwardRef((e,t)=>{let{className:r,...n}=e;return(0,a.jsx)(i.G5,{ref:t,className:(0,c.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",r),...n})});x.displayName=i.G5.displayName;let y=n.forwardRef((e,t)=>{let{className:r,sideOffset:n=4,...l}=e;return(0,a.jsx)(i.ZL,{children:(0,a.jsx)(i.UC,{ref:t,sideOffset:n,className:(0,c.cn)("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",r),...l})})});y.displayName=i.UC.displayName;let I=n.forwardRef((e,t)=>{let{className:r,inset:n,...l}=e;return(0,a.jsx)(i.q7,{ref:t,className:(0,c.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n&&"pl-8",r),...l})});I.displayName=i.q7.displayName;let j=n.forwardRef((e,t)=>{let{className:r,children:n,checked:l,...o}=e;return(0,a.jsxs)(i.H_,{ref:t,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),...void 0!==l&&{checked:l},...o,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(i.VF,{children:(0,a.jsx)(s.S,{className:"h-4 w-4"})})}),n]})});j.displayName=i.H_.displayName;let v=n.forwardRef((e,t)=>{let{className:r,children:n,...l}=e;
1return(0,a.jsxs)(i.hN,{ref:t,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),...l,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(i.VF,{children:(0,a.jsx)(o.G,{className:"h-2 w-2 fill-current"})})}),n]})});v.displayName=i.hN.displayName;let C=n.forwardRef((e,t)=>{let{className:r,inset:n,...l}=e;return(0,a.jsx)(i.JU,{ref:t,className:(0,c.cn)("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",r),...l})});C.displayName=i.JU.displayName;let b=n.forwardRef((e,t)=>{let{className:r,...n}=e;return(0,a.jsx)(i.wv,{ref:t,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",r),...n})});b.displayName=i.wv.displayName},57030:(e,t,r)=>{r.d(t,{EN:()=>c,Eu:()=>s,Hu:()=>d,KH:()=>u,TG:()=>m,U$:()=>a,YY:()=>i,nQ:()=>l});let a={INVOICE:"invoice",ORDER:"order",PACKING_LIST:"packing-list",LOADING_LIST:"loading-list",FREIGHT_QUOTE:"freight-quote",BILL_OF_LADING:"bill-of-lading",BOOKING_CONFIRMATION:"booking-confirmation",CERTIFICATE_OF_ORIGIN:"certificate-of-origin",PHYTOSANITARY_CERTIFICATE:"phytosanitary-certificate",CMR:"cmr",FUMIGATION_CERTIFICATE:"fumigation-certificate",HEALTH_CERTIFICATE:"health-certificate",COURIER_RECEIPT:"courier-receipt",CUSTOMS_DECLARATION:"customs-declaration",AIRWAY_BILL:"airway-bill",DEBIT_NOTE:"debit-note",CREDIT_NOTE:"credit-note",CERTIFICATE_OF_ANALYSIS:"certificate-of-analysis",LAB_TEST_REPORT:"lab-test-report",INSPECTION_CERTIFICATE:"inspection-certificate",WEIGHT_CERTIFICATE:"weight-certificate",INSURANCE_CERTIFICATE:"insurance-certificate",CERTIFICATE_OF_AUTHENTICATION:"certificate-of-authentication",DELIVERY_ORDER:"delivery-order",MULTI_DOCUMENT:"multi-document"},n={[a.BILL_OF_LADING]:"transport",[a.BOOKING_CONFIRMATION]:"transport",[a.CMR]:"transport",[a.INVOICE]:"financial",[a.ORDER]:"financial",[a.FREIGHT_QUOTE]:"financial",[a.PACKING_LIST]:"logistics",[a.LOADING_LIST]:"logistics",[a.CERTIFICATE_OF_ORIGIN]:"compliance",[a.CUSTOMS_DECLARATION]:"compliance",[a.PHYTOSANITARY_CERTIFICATE]:"health",[a.HEALTH_CERTIFICATE]:"health",[a.FUMIGATION_CERTIFICATE]:"treatment",[a.COURIER_RECEIPT]:"logistics",[a.AIRWAY_BILL]:"transport",[a.DEBIT_NOTE]:"financial",[a.CREDIT_NOTE]:"financial",[a.CERTIFICATE_OF_ANALYSIS]:"health",[a.LAB_TEST_REPORT]:"health",[a.INSPECTION_CERTIFICATE]:"compliance",[a.WEIGHT_CERTIFICATE]:"logistics",[a.INSURANCE_CERTIFICATE]:"financial",[a.CERTIFICATE_OF_AUTHENTICATION]:"compliance",[a.DELIVERY_ORDER]:"logistics",[a.MULTI_DOCUMENT]:"container"};function i(e){var t;return e&&null!=(t=n[e])?t:"neutral"}function l(e){return e}let s=[{typeKey:a.BILL_OF_LADING,label:"Bill of Lading",description:"Shipping document issued by carrier acknowledging receipt of cargo",sortOrder:1},{typeKey:a.BOOKING_CONFIRMATION,label:"Booking Confirmation",description:"Pre-carriage document from the carrier confirming a cargo booking â carries a booking number and load itinerary/empty-container pickup details, but no shipped-on-board date and no B/L number. Issued before the goods are loaded, unlike a Bill of Lading.",sortOrder:24},{typeKey:a.PACKING_LIST,label:"Packing List",description:"Detailed list of items in a shipment including quantities and packaging",sortOrder:2},{typeKey:a.INVOICE,label:"Invoice",description:"Commercial invoice detailing goods sold and payment terms",sortOrder:3},{typeKey:a.ORDER,label:"Order",description:"Purchase order or sales order for goods",sortOrder:4},{typeKey:a.CERTIFICATE_OF_ORIGIN,label:"Certificate of Origin",description:"Document certifying the country where goods were manufactured",sortOrder:5},{typeKey:a.FREIGHT_QUOTE,label:"Freight Quote",description:"Price quotation for shipping services from a freight forwarder",sortOrder:6},{typeKey:a.PHYTOSANITARY_CERTIFICATE,label:"Phytosanitary Certificate",description:"Certificate confirming plants/plant products are pest-free",sortOrder:7},{typeKey:a.CMR,label:"CMR (Road Waybill)",description:"International road transport document (NOT a Bill of Lading - for trucks, not ships)",sortOrder:8},{typeKey:a.FUMIGATION_CERTIFICATE,label:"Fumigation Certificate",description:"Certificate confirming cargo has been fumigated for pest control",sortOrder:9},{typeKey:a.HEALTH_CERTIFICATE,label:"Health Certificate",description:"Certificate confirming goods meet health and safety standards",sortOrder:10},{typeKey:a.COURIER_RECEIPT,label:"Courier Receipt",description:"AWB or receipt from courier (DHL, FedEx, UPS, Aramex) for physical shipment of trade documents (original BOLs, certificates, inspection reports) â NOT product shipments",sortOrder:11},{typeKey:a.CUSTOMS_DECLARATION,label:"Customs Declaration",description:"Customs declaration or entry form submitted to customs authorities for import/export clearance",sortOrder:12},{typeKey:a.AIRWAY_BILL,label:"Airway Bill",description:"Air transport document issued by carrier or freight forwarder for air cargo shipments (AWB / MAWB / HAWB)",sortOrder:13},{typeKey:a.DEBIT_NOTE,label:"Debit Note",description:"Document issued to request additional payment â corrects undercharges, adds surcharges, or adjusts a prior invoice upward",sortOrder:14},{typeKey:a.CREDIT_NOTE,label:"Credit Note",description:"Document issued to reduce amount owed â corrects overcharges, handles returns, or adjusts a prior invoice downward",sortOrder:15},{typeKey:a.CERTIFICATE_OF_ANALYSIS,label:"Certificate of Analysis",description:"Manufacturer or lab certificate confirming a product batch meets agreed specifications (COA, MTC, material test certificate)",sortOrder:16},{typeKey:a.LAB_TEST_REPORT,label:"Lab Test Report",description:"Detailed laboratory test report with methodology, sample info, testing parameters, and results (chemical, physical, microbiological analysis)",sortOrder:21},{typeKey:a.INSPECTION_CERTIFICATE,label:"Inspection Certificate",description:"Third-party inspection report (SGS, Bureau Veritas, Intertek) verifying quality, quantity, or condition of goods",sortOrder:17},{typeKey:a.WEIGHT_CERTIFICATE,label:"Weight Certificate",description:"Official weight verification by surveyor, terminal, or weighbridge (includes SOLAS VGM declarations)",sortOrder:18},{typeKey:a.INSURANCE_CERTIFICATE,label:"Insurance Certificate",description:"Proof of cargo insurance coverage for a shipment, often required by letters of credit",sortOrder:19},{typeKey:a.DELIVERY_ORDER,label:"Delivery Order",description:"Port/terminal release document authorizing cargo pickup, issued after freight payment and BL surrender",sortOrder:20},{typeKey:a.CERTIFICATE_OF_AUTHENTICATION,label:"Certificate of Authentication",description:"Seal/stamp authentication issued by chamber of commerce or trade body, certifying a company's seal on a commercial document is genuine",sortOrder:22},{typeKey:a.LOADING_LIST,label:"Loading List",description:"Internal document from the loading team listing what was physically packed into each container/truck â product codes, quantities, pallet breakdowns. Input to outbound packing list generation.",sortOrder:23}],o={[a.INVOICE]:"Invoice",[a.ORDER]:"Order",[a.PACKING_LIST]:"Packing List",[a.LOADING_LIST]:"Loading List",[a.FREIGHT_QUOTE]:"Freight Quote",[a.BILL_OF_LADING]:"Bill of Lading",[a.BOOKING_CONFIRMATION]:"Booking Confirmation",[a.CERTIFICATE_OF_ORIGIN]:"Certificate of Origin",[a.PHYTOSANITARY_CERTIFICATE]:"Phytosanitary Certificate",[a.CMR]:"CMR (Road Waybill)",[a.FUMIGATION_CERTIFICATE]:"Fumigation Certificate",[a.HEALTH_CERTIFICATE]:"Health Certificate",[a.COURIER_RECEIPT]:"Courier Receipt",[a.CUSTOMS_DECLARATION]:"Customs Declaration",[a.AIRWAY_BILL]:"Airway Bill",[a.DEBIT_NOTE]:"Debit Note",[a.CREDIT_NOTE]:"Credit Note",[a.CERTIFICATE_OF_ANALYSIS]:"Certificate of Analysis",[a.LAB_TEST_REPORT]:"Lab Test Report",[a.INSPECTION_CERTIFICATE]:"Inspection Certificate",[a.WEIGHT_CERTIFICATE]:"Weight Certificate",[a.INSURANCE_CERTIFICATE]:"Insurance Certificate",[a.DELIVERY_ORDER]:"Delivery Order",[a.CERTIFICATE_OF_AUTHENTICATION]:"Certificate of Authentication",[a.MULTI_DOCUMENT]:"Multi-Document"};function c(e){return e in o?o[e]:e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}
1function d(e,t){return e||t?"".concat("service"===t?"Service":"Commercial"," ").concat("bill"===e?"Bill":"Invoice"):null}function u(e,t){if(!e&&!t)return null;if(!e)return"service"===t?"Service Order":"Commercial Order";let r="sales_order"===e?"SO":"PO";return"service"===t?"Service ".concat(r):"Commercial ".concat(r)}function m(e){return e?"outbound"===e?"Outbound Packing List":"Inbound Packing List":null}},98590:(e,t,r)=>{r.d(t,{$:()=>f});var a=r(24554),n=r(91394),i=r(93438),l=r(12392),s=r(92650),o=r(70428),c=r(74124),d=r(66573),u=r(27262),m=r(37097),h=r(13565),p=r(9521);function f(e){let{options:t,value:r,onValueChange:f,placeholder:g="Select...",searchPlaceholder:x="Search...",emptyText:y="No results found",disabled:I=!1,className:j,popoverClassName:v,defaultOpen:C=!1,onCancel:b,testId:N,entityLabel:T,entityLabelPlural:E,createMutation:O,formatNewEntity:A,extractId:R}=e,[q,_]=(0,n.useState)(C),[w,S]=(0,n.useState)(""),{t:L}=(0,i.uU)(),[k,F]=(0,n.useState)(!1),P=null!=E?E:"".concat(T,"s"),D=w.trim()&&!t.some(e=>e.label.toLowerCase()===w.trim().toLowerCase()),M=t.find(e=>e.value===r);return(0,a.jsxs)(h.AM,{open:q,onOpenChange:e=>{_(e),e||(k||null==b||b(),F(!1),S(""))},children:[(0,a.jsx)(h.Wv,{asChild:!0,children:(0,a.jsxs)(u.$,{variant:"outline",role:"combobox","aria-expanded":q,disabled:I,"data-testid":N,className:(0,d.cn)("w-full justify-between bg-background font-normal",!M&&"text-muted-foreground",j),children:[(0,a.jsx)("span",{className:"truncate text-left",children:M?M.label:g}),(0,a.jsx)(l.m,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,a.jsx)(h.hl,{className:(0,d.cn)("w-[var(--radix-popover-trigger-width)] p-0",v),align:"start",children:(0,a.jsxs)(m.uB,{shouldFilter:!1,children:[(0,a.jsx)(m.G7,{placeholder:0===t.length?L("products.comboboxCreate.typeToCreatePlaceholder",{entity:T}):x,value:w,onValueChange:S}),(0,a.jsxs)(m.oI,{children:[!w&&0===t.length&&(0,a.jsxs)("div",{className:"px-2 py-6 text-center",children:[(0,a.jsx)(s.c,{className:"mx-auto h-6 w-6 text-muted-foreground mb-2"}),(0,a.jsx)("p",{className:"text-sm font-medium",children:L("products.comboboxCreate.noneYet",{entities:P})}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:L("products.comboboxCreate.typeToCreateFirst",{entity:T})})]}),w&&0===t.length&&!D&&(0,a.jsx)(m.xL,{children:y}),(0,a.jsxs)(m.L$,{children:[t.filter(e=>!w||e.label.toLowerCase().includes(w.toLowerCase())).map(e=>(0,a.jsxs)(m.h_,{value:e.value,onSelect:()=>{let t=e.value===r?null:e.value;F(!0),f(t),_(!1),S("")},children:[(0,a.jsx)(o.S,{className:(0,d.cn)("mr-2 h-4 w-4",r===e.value?"opacity-100":"opacity-0")}),e.label]},e.value)),D&&(0,a.jsx)(m.h_,{onSelect:()=>{let e=w.trim();if(!e)return;let t=A(e);O.mutate(t,{onSuccess:e=>{let t=R(e);F(!0),f(t),setTimeout(()=>{_(!1),S("")},100)},onError:e=>{p.oR.error(L("shell.shared.comboboxInlineCreate.error"),{description:e instanceof Error?e.message:"Failed to create ".concat(T)})}})},className:"text-primary font-medium",disabled:O.isPending,"data-testid":N?"".concat(N,"-create"):void 0,children:O.isPending?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.N,{className:"mr-2 h-4 w-4 animate-spin"}),L("shell.shared.comboboxInlineCreate.creating")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.c,{className:"mr-2 h-4 w-4"}),L("products.comboboxCreate.createOption",{name:w.trim()})]})})]})]})]})})]})}}}]);
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.