(()=>{var a={};a.id=2452,a.ids=[2452],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},2727:(a,b,c)=>{"use strict";c.d(b,{z:()=>i});var d=c(21124),e=c(3991),f=c.n(e),g=c(8294),h=c(44943);function i({title:a,description:b,breadcrumbs:c,actions:e,badge:i,className:j}){return(0,d.jsxs)("div",{className:(0,h.cn)("mb-6",j),children:[c&&c.length>0&&(0,d.jsx)("nav",{className:"flex items-center gap-1 text-[12px] text-muted-foreground mb-2.5","aria-label":"Breadcrumb",children:c.map((a,b)=>(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[a.href?(0,d.jsx)(f(),{href:a.href,className:"hover:text-foreground transition",children:a.label}):(0,d.jsx)("span",{className:"text-foreground font-medium",children:a.label}),b<c.length-1&&(0,d.jsx)(g.A,{className:"h-3.5 w-3.5 text-muted-foreground/60"})]},b))}),(0,d.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,d.jsx)("h1",{className:"text-[22px] md:text-[26px] font-bold tracking-tight text-foreground",children:a}),i]}),b&&(0,d.jsx)("p",{className:"mt-1 text-[13.5px] text-muted-foreground leading-relaxed max-w-3xl",children:b})]}),e&&(0,d.jsx)("div",{className:"flex items-center gap-2 flex-wrap shrink-0",children:e})]})]})}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},14257:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(23339).A)("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]])},17584:(a,b,c)=>{"use strict";c.d(b,{W:()=>h});var d=c(21124),e=c(44943);let f={success:"bg-emerald-50 text-emerald-700 border-emerald-200",pending:"bg-amber-50 text-amber-700 border-amber-200",warning:"bg-orange-50 text-orange-700 border-orange-200",danger:"bg-red-50 text-red-700 border-red-200",info:"bg-sky-50 text-sky-700 border-sky-200",neutral:"bg-muted text-muted-foreground border-border",gold:"bg-gold-50 text-gold-700 border-gold-200",processing:"bg-indigo-50 text-indigo-700 border-indigo-200"},g={success:"bg-emerald-500",pending:"bg-amber-500",warning:"bg-orange-500",danger:"bg-red-500",info:"bg-sky-500",neutral:"bg-muted-foreground/60",gold:"bg-gold-500",processing:"bg-indigo-500"};function h({tone:a,children:b,dot:c=!0,className:h,size:i="md"}){return(0,d.jsxs)("span",{className:(0,e.cn)("inline-flex items-center gap-1.5 rounded-full border font-medium whitespace-nowrap","sm"===i?"px-2 py-0.5 text-[10.5px]":"px-2.5 py-1 text-[11.5px]",f[a],h),children:[c&&(0,d.jsx)("span",{className:(0,e.cn)("h-1.5 w-1.5 rounded-full",g[a])}),(0,d.jsx)("span",{children:b})]})}},17693:(a,b,c)=>{"use strict";c.d(b,{PL:()=>l,an:()=>j,mL:()=>k});var d=c(38301),e=c(73852),f=c(45478),g=c(64158);let h={history:[],approvals:[],postings:null,walletMovements:[],inventoryMovements:[],journals:[],auditLogs:[],voucher:null};function i(a){return a&&"object"==typeof a&&"data"in a?a.data:a}function j(a){if(e.A.isAxiosError(a)){let b=a.response?.data?.detail;return"string"==typeof b?b:b&&"object"==typeof b?b.message||b.error_code||"Buy order request failed":a.response?.data?.message||a.message}return a instanceof Error?a.message:"Buy order request failed"}function k(a,b="buy-voucher"){let c=window.open("","_blank","width=920,height=1100");if(!c)throw Error("Popup blocked. Allow popups to print the voucher.");let d=a.items.map((a,b)=>`
    <tr>
      <td>${b+1}</td>
      <td>${a.metal_type||"gold"}</td>
      <td>${a.weight_grams}</td>
      <td>${a.quantity}</td>
      <td>${a.price_per_gram}</td>
      <td>${a.premium}</td>
      <td>${a.line_total}</td>
    </tr>
  `).join("");c.document.open(),c.document.write(`
    <!doctype html>
    <html>
      <head>
        <title>${b}</title>
        <style>
          body { font-family: Arial, sans-serif; color: #111827; margin: 28px; }
          header { display: flex; justify-content: space-between; border-bottom: 2px solid #d4af37; padding-bottom: 16px; margin-bottom: 20px; }
          h1 { font-size: 22px; margin: 0 0 6px; }
          table { width: 100%; border-collapse: collapse; margin-top: 16px; }
          th, td { border: 1px solid #e5e7eb; padding: 8px; font-size: 12px; text-align: left; }
          th { background: #f8fafc; }
          .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; font-size: 13px; }
          .totals { width: 320px; margin-left: auto; margin-top: 18px; }
          .totals div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #e5e7eb; }
          button { margin-top: 24px; padding: 8px 14px; }
          @media print { button { display: none; } body { margin: 18px; } }
        </style>
      </head>
      <body>
        <header>
          <div>
            <h1>Buy Gold Voucher</h1>
            <div>${a.order_no}</div>
          </div>
          <div>Status: ${a.status}</div>
        </header>
        <section class="grid">
          <div><strong>Order type:</strong> ${a.order_type}</div>
          <div><strong>Created:</strong> ${a.created_at||"-"}</div>
          <div><strong>Supplier:</strong> ${a.supplier_id||"-"}</div>
          <div><strong>Customer:</strong> ${a.customer_id||"-"}</div>
          <div><strong>Currency:</strong> ${a.currency?.code||a.currency?.name_en||"-"}</div>
          <div><strong>Posted:</strong> ${a.posted_at||"-"}</div>
        </section>
        <table>
          <thead><tr><th>#</th><th>Metal</th><th>Weight</th><th>Qty</th><th>Price/g</th><th>Premium</th><th>Total</th></tr></thead>
          <tbody>${d||'<tr><td colspan="7">No items</td></tr>'}</tbody>
        </table>
        <section class="totals">
          <div><span>Subtotal</span><strong>${a.subtotal_amount}</strong></div>
          <div><span>Fees</span><strong>${a.fee_amount}</strong></div>
          <div><span>Tax</span><strong>${a.tax_amount}</strong></div>
          <div><span>Discount</span><strong>${a.discount_amount}</strong></div>
          <div><span>Total</span><strong>${a.total_amount}</strong></div>
        </section>
        <button onclick="window.print()">Print</button>
      </body>
    </html>
  `),c.document.close(),c.focus()}function l(){let[a,b]=(0,d.useState)([]),[c,e]=(0,d.useState)(null),[k,l]=(0,d.useState)(h),[m,n]=(0,d.useState)(0),[o,p]=(0,d.useState)(1),[q,r]=(0,d.useState)(!1),[s,t]=(0,d.useState)(!1),[u,v]=(0,d.useState)(null),w=(0,d.useCallback)(async(a={})=>{r(!0),v(null);try{let c=await f.api.get(g.H.BUY_ORDERS.LIST,{params:{skip:0,limit:500,req_status:a.status||void 0,buy_order_type:a.buy_order_type||void 0}}),d=function(a){let b=i(a);return Array.isArray(b)?b:b?.items??[]}(c),e=function(a,b){let c=b.search?.trim().toLowerCase();return a.filter(a=>!(b.status&&a.status!==b.status||b.buy_order_type&&a.buy_order_type!==b.buy_order_type||b.currency_id&&a.currency_id!==b.currency_id||b.branch_id&&a.target_branch_id!==b.branch_id||b.vault_id&&a.target_vault_id!==b.vault_id||b.customer_id&&a.customer_id!==b.customer_id||b.supplier_id&&a.supplier_id!==b.supplier_id||b.date_from&&new Date(a.created_at)<new Date(b.date_from)||b.date_to&&new Date(a.created_at)>new Date(`${b.date_to}T23:59:59`))&&(!c||[a.buy_order_no,a.status,a.buy_order_type,a.customer_id,a.supplier_id,a.purchase_request_no,a.supplier_reference,a.external_reference].some(a=>String(a??"").toLowerCase().includes(c))))}(d,a),h=a.page??1,j=a.page_size??25,k=e.slice((h-1)*j,h*j);return b(k),n(e.length),p(Math.max(1,Math.ceil(e.length/j))),{items:k,total:e.length,page:h,page_size:j,pages:Math.max(1,Math.ceil(e.length/j))}}catch(a){return v(j(a)),null}finally{r(!1)}},[]),x=(0,d.useCallback)(async a=>{r(!0),v(null);try{let b=i(await f.api.get(g.H.BUY_ORDERS.GET_BY_ID(a)));return e(b),b}catch(a){return v(j(a)),null}finally{r(!1)}},[]),y=(0,d.useCallback)(async a=>{t(!0);try{return i(await f.api.post(g.H.BUY_ORDERS.CREATE,a))}finally{t(!1)}},[]),z=(0,d.useCallback)((a,b,c)=>f.api.post(g.H.BUY_ORDERS.COMPUTE_PRICE,{purity_id:a,currency_id:b,product_id:c||void 0}).then(i),[]),A=(0,d.useCallback)((a,b)=>f.api.post(g.H.BUY_ORDERS.ITEMS(a),b).then(i),[]),B=(0,d.useCallback)((a,b)=>f.api.del(g.H.BUY_ORDERS.ITEM(a,b)),[]),C=(0,d.useCallback)(a=>f.api.post(g.H.BUY_ORDERS.RECALCULATE(a)).then(i),[]);return{items:a,selected:c,support:k,total:m,pages:o,isLoading:q,isSubmitting:s,error:u,list:w,get:x,create:y,quote:z,addItem:A,deleteItem:B,recalculate:C,act:(0,d.useCallback)(async(a,b,c={})=>{let d=g.H.BUY_ORDERS,e={submit:d.SUBMIT_FOR_REVIEW(a),review:d.SUBMIT_FOR_APPROVAL(a),approve:d.APPROVE(a),reject:d.REJECT(a),cancel:d.CANCEL(a),post:d.POST_APPROVAL(a),send:d.SEND_TO_SUPPLIER(a),partial:d.MARK_PARTIALLY_SUPPLIED(a),full:d.MARK_FULLY_SUPPLIED(a),close:d.CLOSE(a),"post-supply":d.POST_SUPPLY(a),"post-buyback":d.POST_BUYBACK(a),reverse:d.REVERSE(a)},h="cancel"===b||"reverse"===b?{reason:c.reason}:"post"===b?void 0:"post-supply"===b?{receiving_vault_id:c.receiving_vault_id||null}:"post-buyback"===b?c.customer_user_id?{customer_user_id:c.customer_user_id}:{}:{note:c.reason||null};t(!0);try{return i(await f.api.post(e[b],h))}finally{t(!1)}},[]),loadSupport:(0,d.useCallback)(async(a,b)=>{let c=g.H.BUY_ORDERS,d=[f.api.get(c.STATUS_HISTORY(a)),f.api.get(c.APPROVALS(a)),f.api.get(c.POSTINGS(a)),f.api.get(g.H.AUDIT_LOGS.LIST,{params:{entity_type:"buy_order",entity_id:a}})],e=await Promise.allSettled(d),h=(a,b)=>"fulfilled"===e[a].status?i(e[a].value):b,j=h(0,[]),k=h(1,[]),m={history:j,approvals:k,postings:h(2,null),walletMovements:[],inventoryMovements:[],journals:[],auditLogs:h(3,{items:[]}).items??[],voucher:b?{order_id:b.id,order_no:b.buy_order_no,order_type:b.buy_order_type,status:b.status,supplier_id:b.supplier_id,customer_id:b.customer_id,currency:b.currency,items:b.items??[],subtotal_amount:b.subtotal_amount,fee_amount:b.fee_amount,tax_amount:b.tax_amount,discount_amount:b.discount_amount,total_amount:b.total_amount,created_at:b.created_at,approved_at:b.approved_at,posted_at:b.posted_at}:null};return l(m),m},[])}}},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},25345:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(23339).A)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},26850:(a,b,c)=>{"use strict";c.d(b,{Cf:()=>j,PM:()=>k,Td:()=>e,Xh:()=>d,df:()=>f,e6:()=>i});let d={draft:"neutral",pending_review:"pending",pending_approval:"warning",approved:"success",posted:"success",sent_to_supplier:"info",partially_supplied:"warning",fully_supplied:"success",rejected:"danger",cancelled:"neutral",closed:"neutral"},e={draft:{en:"Draft",ar:"مسودة"},pending_review:{en:"Pending review",ar:"بانتظار المراجعة"},pending_approval:{en:"Pending approval",ar:"بانتظار الاعتماد"},approved:{en:"Approved",ar:"معتمد"},posted:{en:"Posted",ar:"مرحل"},sent_to_supplier:{en:"Sent to supplier",ar:"مرسل للمورد"},partially_supplied:{en:"Partially supplied",ar:"مورد جزئيا"},fully_supplied:{en:"Fully supplied",ar:"مورد بالكامل"},rejected:{en:"Rejected",ar:"مرفوض"},cancelled:{en:"Cancelled",ar:"ملغي"},closed:{en:"Closed",ar:"مغلق"}},f={supplier:{en:"Supplier purchase",ar:"شراء من مورد"},customer_buyback:{en:"Customer buyback",ar:"شراء من عميل"}},g={submit:"buy_orders:update",review:"buy_orders:review",approve:"buy_orders:approve",reject:"buy_orders:review",cancel:"buy_orders:cancel",post:"buy_orders:post",send:"buy_orders:approve",partial:"buy_orders:update",full:"buy_orders:update",close:"buy_orders:approve","post-supply":"buy_orders:post","post-buyback":"buy_orders:post",reverse:"buy_orders:reverse",recalculate:"buy_orders:update"},h={draft:["recalculate","submit","cancel"],pending_review:["review","reject","cancel"],pending_approval:["approve","reject","cancel"],approved:["send","post","post-buyback","cancel"],posted:["send","reverse"],sent_to_supplier:["partial","cancel"],partially_supplied:["full","post-supply","cancel"],fully_supplied:["post-supply","close"]};function i(a,b=[],c){return(h[a]??[]).filter(a=>"customer_buyback"===c?!["send","partial","full","post-supply"].includes(a):"post-buyback"!==a).filter(a=>b.includes(g[a]))}function j(a){let b=new Set(a?.permissions||[]),c=new Set([a?.role,...(a?.roles||[]).map(a=>a.code)].filter(Boolean));return a?.user_type==="admin"||c.has("super_admin")?[...b,"buy_orders:read","buy_orders:create","buy_orders:update","buy_orders:review","buy_orders:approve","buy_orders:post","buy_orders:cancel","buy_orders:reverse","buy_orders:attachments","buy_orders:print"]:c.has("operations_manager")?[...b,"buy_orders:read","buy_orders:create","buy_orders:update","buy_orders:review","buy_orders:cancel","buy_orders:attachments","buy_orders:print"]:c.has("finance_officer")?[...b,"buy_orders:read","buy_orders:review","buy_orders:approve","buy_orders:post","buy_orders:cancel","buy_orders:reverse","buy_orders:print"]:c.has("warehouse_admin")?[...b,"buy_orders:read","buy_orders:update","buy_orders:post","buy_orders:attachments","buy_orders:print"]:[...b]}function k(a,b="en"){return"customer_buyback"===a.buy_order_type?("ar"===b?a.customer?.full_name_ar:a.customer?.full_name_en)||a.customer?.customer_code||a.customer_id||"-":("ar"===b?a.supplier?.name_ar:a.supplier?.name_en)||a.supplier?.code||a.supplier_id||"-"}},27910:a=>{"use strict";a.exports=require("stream")},28241:(a,b,c)=>{"use strict";c.d(b,{N:()=>k,a:()=>j});var d=c(21124),e=c(38301),f=c(23312),g=c(47089),h=c(44943),i=c(4374);function j({open:a,onClose:b,title:c,description:j,size:k="md",children:l,footer:m,overflowVisible:n=!1}){let[o,p]=e.useState(!1);return(e.useEffect(()=>{p(!0)},[]),e.useEffect(()=>{if(!a)return;let c=a=>{"Escape"===a.key&&b()};return document.addEventListener("keydown",c),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",c),document.body.style.overflow=""}},[a,b]),o&&a)?(0,f.createPortal)((0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",dir:"rtl",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:b,"aria-hidden":"true"}),(0,d.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"modal-title",className:(0,h.cn)("relative w-full rounded-xl border border-border bg-card shadow-2xl",!n&&"overflow-hidden","sm"===k&&"max-w-md","md"===k&&"max-w-lg","lg"===k&&"max-w-3xl"),children:[(0,d.jsxs)("div",{className:(0,h.cn)("flex items-start justify-between gap-4 border-b border-border bg-muted/40 px-5 py-4",!n&&"rounded-t-xl"),children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{id:"modal-title",className:"text-base font-semibold text-foreground",children:c}),j?(0,d.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:j}):null]}),(0,d.jsx)("button",{type:"button",onClick:b,className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":i.A.t("components.ui.modal.text_1"),children:(0,d.jsx)(g.A,{className:"h-4 w-4"})})]}),(0,d.jsx)("div",{className:"px-5 py-5",children:l}),m?(0,d.jsx)("div",{className:(0,h.cn)("flex items-center justify-start gap-2 border-t border-border bg-muted/30 px-5 py-3",!n&&"rounded-b-xl"),children:m}):null]})]}),document.body):null}function k({children:a}){return(0,d.jsx)("div",{className:"flex items-center justify-start gap-2",children:a})}},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},34631:a=>{"use strict";a.exports=require("tls")},35284:(a,b,c)=>{"use strict";c.d(b,{$:()=>g});var d=c(21124),e=c(38301),f=c(44943);let g=e.forwardRef(function({className:a,variant:b="primary",size:c="md",isLoading:e,children:g,disabled:h,...i},j){return(0,d.jsxs)("button",{ref:j,...i,disabled:e||h,className:(({variant:a="primary",size:b="md",className:c}={})=>(0,f.cn)("inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gold-500/40","sm"===b?"h-8 px-3 text-xs":"h-10 px-4 text-sm","primary"===a&&"bg-gold-500 text-ink-900 hover:bg-gold-600 shadow-sm","secondary"===a&&"bg-ink-900 text-gold-50 hover:bg-ink-800 shadow-sm","outline"===a&&"border border-border bg-card text-foreground hover:bg-muted","ghost"===a&&"text-foreground hover:bg-muted","danger"===a&&"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm",c))({variant:b,size:c,className:a}),children:[e?(0,d.jsx)("span",{className:"mr-2 inline-block h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}):null,g]})})},38177:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(97954).registerClientReference)(function(){throw Error("Attempted to call the default export of \"D:\\\\Arab Ware Dos\\\\Gold App\\\\gold_wallet\\\\gold_wallet-dev\\\\src\\\\app\\\\(admin)\\\\buy-orders\\\\[id]\\\\page.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"D:\\Arab Ware Dos\\Gold App\\gold_wallet\\gold_wallet-dev\\src\\app\\(admin)\\buy-orders\\[id]\\page.tsx","default")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},42513:(a,b,c)=>{"use strict";c.d(b,{FO:()=>f,l2:()=>g,zM:()=>h});var d=c(21124);c(38301);var e=c(4374);function f({label:a,id:b,name:c,type:e="text",value:f,onChange:g,error:h,required:i,placeholder:j,disabled:k,accept:l,min:m,max:n,step:o}){return(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("label",{htmlFor:b,className:"block text-sm font-medium text-foreground",children:[a,i&&(0,d.jsx)("span",{className:"text-destructive mr-1",children:"*"})]}),(0,d.jsx)("input",{type:e,id:b,name:c,value:f,onChange:g,placeholder:j,disabled:k,accept:l,min:m,max:n,step:o,required:i,className:`w-full px-3 py-2.5 text-sm border rounded-lg bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed ${h?"border-destructive":"border-border"}`}),h&&(0,d.jsx)("p",{className:"text-destructive text-xs",children:h})]})}function g({label:a,id:b,name:c,value:e,onChange:f,error:g,required:h,placeholder:i,disabled:j,rows:k=3}){return(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("label",{htmlFor:b,className:"block text-sm font-medium text-foreground",children:[a,h&&(0,d.jsx)("span",{className:"text-destructive mr-1",children:"*"})]}),(0,d.jsx)("textarea",{id:b,name:c,value:e,onChange:f,placeholder:i,disabled:j,required:h,rows:k,className:`w-full px-3 py-2.5 text-sm border rounded-lg bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary resize-none disabled:opacity-50 disabled:cursor-not-allowed ${g?"border-destructive":"border-border"}`}),g&&(0,d.jsx)("p",{className:"text-destructive text-xs",children:g})]})}function h({label:a,id:b,name:c,value:f,onChange:g,options:h,error:i,required:j,disabled:k,placeholder:l=e.A.t("components.ui.FormFields.text_1")}){return(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("label",{htmlFor:b,className:"block text-sm font-medium text-foreground",children:[a,j&&(0,d.jsx)("span",{className:"text-destructive mr-1",children:"*"})]}),(0,d.jsxs)("select",{id:b,name:c,value:f,onChange:g,disabled:k,required:j,className:`w-full px-3 py-2.5 text-sm border rounded-lg bg-background text-foreground cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed ${i?"border-destructive":"border-border"}`,children:[(0,d.jsx)("option",{value:"",children:l}),h.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))]}),i&&(0,d.jsx)("p",{className:"text-destructive text-xs",children:i})]})}},47089:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(23339).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},54450:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>E.a,__next_app__:()=>K,handler:()=>M,pages:()=>J,routeModule:()=>L,tree:()=>I});var d=c(49754),e=c(9117),f=c(46595),g=c(32324),h=c(39326),i=c(38928),j=c(20175),k=c(12),l=c(54290),m=c(12696),n=c(52574),o=c(82802),p=c(77533),q=c(45229),r=c(32822),s=c(261),t=c(26453),u=c(52474),v=c(26713),w=c(51356),x=c(62685),y=c(36225),z=c(63446),A=c(2762),B=c(45742),C=c(86439),D=c(81170),E=c.n(D),F=c(62506),G=c(91203),H={};for(let a in F)0>["default","tree","pages","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(H[a]=()=>F[a]);c.d(b,H);let I={children:["",{children:["(admin)",{children:["buy-orders",{children:["[id]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,38177)),"D:\\Arab Ware Dos\\Gold App\\gold_wallet\\gold_wallet-dev\\src\\app\\(admin)\\buy-orders\\[id]\\page.tsx"]}]},{}]},{}]},{layout:[()=>Promise.resolve().then(c.bind(c,43913)),"D:\\Arab Ware Dos\\Gold App\\gold_wallet\\gold_wallet-dev\\src\\app\\(admin)\\layout.tsx"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,87028,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,90461,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,32768,23)),"next/dist/client/components/builtin/unauthorized.js"]}]},{layout:[()=>Promise.resolve().then(c.bind(c,51472)),"D:\\Arab Ware Dos\\Gold App\\gold_wallet\\gold_wallet-dev\\src\\app\\layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,81170,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,87028,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,90461,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,32768,23)),"next/dist/client/components/builtin/unauthorized.js"]}]}.children,J=["D:\\Arab Ware Dos\\Gold App\\gold_wallet\\gold_wallet-dev\\src\\app\\(admin)\\buy-orders\\[id]\\page.tsx"],K={require:c,loadChunk:()=>Promise.resolve()},L=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/(admin)/buy-orders/[id]/page",pathname:"/buy-orders/[id]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:I},distDir:".next",relativeProjectDir:""});async function M(a,b,d){var D;let H="/(admin)/buy-orders/[id]/page";"/index"===H&&(H="/");let N=(0,h.getRequestMeta)(a,"postponed"),O=(0,h.getRequestMeta)(a,"minimalMode"),P=await L.prepare(a,b,{srcPage:H,multiZoneDraftMode:!1});if(!P)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:Q,query:R,params:S,parsedUrl:T,pageIsDynamic:U,buildManifest:V,nextFontManifest:W,reactLoadableManifest:X,serverActionsManifest:Y,clientReferenceManifest:Z,subresourceIntegrityManifest:$,prerenderManifest:_,isDraftMode:aa,resolvedPathname:ab,revalidateOnlyGenerated:ac,routerServerContext:ad,nextConfig:ae,interceptionRoutePatterns:af}=P,ag=T.pathname||"/",ah=(0,s.normalizeAppPath)(H),{isOnDemandRevalidate:ai}=P,aj=L.match(ag,_),ak=!!_.routes[ab],al=!!(aj||ak||_.routes[ah]),am=a.headers["user-agent"]||"",an=(0,v.getBotType)(am),ao=(0,q.isHtmlBotRequest)(a),ap=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[u.NEXT_ROUTER_PREFETCH_HEADER],aq=(0,h.getRequestMeta)(a,"isRSCRequest")??(0,n.f)(a.headers[u.RSC_HEADER]),ar=(0,t.getIsPossibleServerAction)(a),as=(0,m.checkIsAppPPREnabled)(ae.experimental.ppr)&&(null==(D=_.routes[ah]??_.dynamicRoutes[ah])?void 0:D.renderingMode)==="PARTIALLY_STATIC",at=!1,au=!1,av=as?N:void 0,aw=as&&aq&&!ap,ax=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),ay=!am||(0,q.shouldServeStreamingMetadata)(am,ae.htmlLimitedBots);ao&&as&&(al=!1,ay=!1);let az=!0===L.isDev||!al||"string"==typeof N||aw,aA=ao&&as,aB=null;aa||!al||az||ar||av||aw||(aB=ab);let aC=aB;!aC&&L.isDev&&(aC=ab),L.isDev||aa||!al||!aq||aw||(0,k.d)(a.headers);let aD={...F,tree:I,pages:J,GlobalError:E(),handler:M,routeModule:L,__next_app__:K};Y&&Z&&(0,p.setReferenceManifestsSingleton)({page:H,clientReferenceManifest:Z,serverActionsManifest:Y,serverModuleMap:(0,r.createServerModuleMap)({serverActionsManifest:Y})});let aE=a.method||"GET",aF=(0,g.getTracer)(),aG=aF.getActiveScopeSpan();try{let f=L.getVaryHeader(ab,af);b.setHeader("Vary",f);let k=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return L.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=aF.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${aE} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aE} ${a.url}`)})},m=async({span:e,postponed:f,fallbackRouteParams:g})=>{let i={query:R,params:S,page:ah,sharedContext:{buildId:Q},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aD,Component:(0,j.T)(aD),params:S,routeModule:L,page:H,postponed:f,shouldWaitOnAllReady:aA,serveStreamingMetadata:ay,supportsDynamicResponse:"string"==typeof f||az,buildManifest:V,nextFontManifest:W,reactLoadableManifest:X,subresourceIntegrityManifest:$,serverActionsManifest:Y,clientReferenceManifest:Z,setIsrStatus:null==ad?void 0:ad.setIsrStatus,dir:c(33873).join(process.cwd(),L.relativeProjectDir),isDraftMode:aa,isRevalidate:al&&!f&&!aw,botType:an,isOnDemandRevalidate:ai,isPossibleServerAction:ar,assetPrefix:ae.assetPrefix,nextConfigOutput:ae.output,crossOrigin:ae.crossOrigin,trailingSlash:ae.trailingSlash,previewProps:_.preview,deploymentId:ae.deploymentId,enableTainting:ae.experimental.taint,htmlLimitedBots:ae.htmlLimitedBots,devtoolSegmentExplorer:ae.experimental.devtoolSegmentExplorer,reactMaxHeadersLength:ae.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:ae.experimental.cacheLife,basePath:ae.basePath,serverActions:ae.experimental.serverActions,...at?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isRevalidate:!0,isDebugDynamicAccesses:at}:{},experimental:{isRoutePPREnabled:as,expireTime:ae.expireTime,staleTimes:ae.experimental.staleTimes,cacheComponents:!!ae.experimental.cacheComponents,clientSegmentCache:!!ae.experimental.clientSegmentCache,clientParamParsing:!!ae.experimental.clientParamParsing,dynamicOnHover:!!ae.experimental.dynamicOnHover,inlineCss:!!ae.experimental.inlineCss,authInterrupts:!!ae.experimental.authInterrupts,clientTraceMetadata:ae.experimental.clientTraceMetadata||[]},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d)=>L.onRequestError(a,b,d,ad),err:(0,h.getRequestMeta)(a,"invokeError"),dev:L.isDev}},l=await k(e,i),{metadata:m}=l,{cacheControl:n,headers:o={},fetchTags:p}=m;if(p&&(o[z.NEXT_CACHE_TAGS_HEADER]=p),a.fetchMetrics=m.fetchMetrics,al&&(null==n?void 0:n.revalidate)===0&&!L.isDev&&!as){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ab}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:w.CachedRouteKind.APP_PAGE,html:l,headers:o,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},n=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i})=>{let j,k=!1===L.isDev,l=c||b.writableEnded;if(ai&&ac&&!f&&!O)return(null==ad?void 0:ad.render404)?await ad.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(aj&&(j=(0,x.parseFallbackField)(aj.fallback)),j===x.FallbackMode.PRERENDER&&(0,v.isBot)(am)&&(!as||ao)&&(j=x.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ai=!0),ai&&(j!==x.FallbackMode.NOT_FOUND||f)&&(j=x.FallbackMode.BLOCKING_STATIC_RENDER),!O&&j!==x.FallbackMode.BLOCKING_STATIC_RENDER&&aC&&!l&&!aa&&U&&(k||!ak)){let b;if((k||aj)&&j===x.FallbackMode.NOT_FOUND)throw new C.NoFallbackError;if(as&&!aq){let c="string"==typeof(null==aj?void 0:aj.fallback)?aj.fallback:k?ah:null;if(b=await L.handleResponse({cacheKey:c,req:a,nextConfig:ae,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:_,isRoutePPREnabled:as,responseGenerator:async()=>m({span:i,postponed:void 0,fallbackRouteParams:k||au?(0,o.u)(ah):null}),waitUntil:d.waitUntil}),null===b)return null;if(b)return delete b.cacheControl,b}}let n=ai||g||!av?void 0:av;if(at&&void 0!==n)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:w.CachedRouteKind.PAGES,html:y.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let p=U&&as&&((0,h.getRequestMeta)(a,"renderFallbackShell")||au)?(0,o.u)(ag):null;return m({span:i,postponed:n,fallbackRouteParams:p})},p=async c=>{var f,g,i,j,k;let l,o=await L.handleResponse({cacheKey:aB,responseGenerator:a=>n({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ai,isRoutePPREnabled:as,req:a,nextConfig:ae,prerenderManifest:_,waitUntil:d.waitUntil});if(aa&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!o){if(aB)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=o.value)?void 0:f.kind)!==w.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=o.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let p="string"==typeof o.value.postponed;al&&!aw&&(!p||ap)&&(O||b.setHeader("x-nextjs-cache",ai?"REVALIDATED":o.isMiss?"MISS":o.isStale?"STALE":"HIT"),b.setHeader(u.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=o;if(av)l={revalidate:0,expire:void 0};else if(O&&aq&&!ap&&as)l={revalidate:0,expire:void 0};else if(!L.isDev)if(aa)l={revalidate:0,expire:void 0};else if(al){if(o.cacheControl)if("number"==typeof o.cacheControl.revalidate){if(o.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${o.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:o.cacheControl.revalidate,expire:(null==(j=o.cacheControl)?void 0:j.expire)??ae.expireTime}}else l={revalidate:z.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(o.cacheControl=l,"string"==typeof ax&&(null==q?void 0:q.kind)===w.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(u.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[z.NEXT_CACHE_TAGS_HEADER];O&&al&&c&&"string"==typeof c&&b.setHeader(z.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ax);return void 0!==d?(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:y.default.fromStatic(d,u.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl}):(b.statusCode=204,(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:y.default.EMPTY,cacheControl:o.cacheControl}))}let r=(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r({...o,value:{...o.value,kind:"PAGE"}},{url:(0,h.getRequestMeta)(a,"initURL")}))return null;if(p&&av)throw Object.defineProperty(Error("Invariant: postponed state should not be present on a resume request"),"__NEXT_ERROR_CODE",{value:"E396",enumerable:!1,configurable:!0});if(q.headers){let a={...q.headers};for(let[c,d]of(O&&al||delete a[z.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let s=null==(g=q.headers)?void 0:g[z.NEXT_CACHE_TAGS_HEADER];if(O&&al&&s&&"string"==typeof s&&b.setHeader(z.NEXT_CACHE_TAGS_HEADER,s),!q.status||aq&&as||(b.statusCode=q.status),!O&&q.status&&G.RedirectStatusCode[q.status]&&aq&&(b.statusCode=200),p&&b.setHeader(u.NEXT_DID_POSTPONE_HEADER,"1"),aq&&!aa){if(void 0===q.rscData){if(q.postponed)throw Object.defineProperty(Error("Invariant: Expected postponed to be undefined"),"__NEXT_ERROR_CODE",{value:"E372",enumerable:!1,configurable:!0});return(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:q.html,cacheControl:aw?{revalidate:0,expire:void 0}:o.cacheControl})}return(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:y.default.fromStatic(q.rscData,u.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl})}let t=q.html;if(!p||O||aq)return(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:t,cacheControl:o.cacheControl});if(at)return t.push(new ReadableStream({start(a){a.enqueue(A.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}});let v=new TransformStream;return t.push(v.readable),m({span:c,postponed:q.postponed,fallbackRouteParams:null}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==w.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(v.writable)}).catch(a=>{v.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}})};if(!aG)return await aF.withPropagatedContext(a.headers,()=>aF.trace(i.BaseServerSpan.handleRequest,{spanName:`${aE} ${a.url}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aE,"http.target":a.url}},p));await p(aG)}catch(b){throw b instanceof C.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:H,routeType:"render",revalidateReason:(0,f.c)({isRevalidate:al,isOnDemandRevalidate:ai})},ad),b}}},55511:a=>{"use strict";a.exports=require("crypto")},55591:a=>{"use strict";a.exports=require("https")},55750:(a,b,c)=>{Promise.resolve().then(c.bind(c,88987))},59268:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(23339).A)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65236:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(23339).A)("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]])},73054:(a,b,c)=>{Promise.resolve().then(c.bind(c,38177))},73496:a=>{"use strict";a.exports=require("http2")},74075:a=>{"use strict";a.exports=require("zlib")},79551:a=>{"use strict";a.exports=require("url")},79944:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(23339).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},81630:a=>{"use strict";a.exports=require("http")},83997:a=>{"use strict";a.exports=require("tty")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},88987:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>H});var d=c(21124),e=c(38301),f=c(42378),g=c(25345),h=c(71563),i=c(54937),j=c(59268),k=c(91292),l=c(65236),m=c(55937),n=c(7922),o=c(9212),p=c(79944),q=c(14257),r=c(42830),s=c(43401),t=c(45817),u=c(17693),v=c(26850),w=c(2727),x=c(95360),y=c(17584),z=c(35284),A=c(28241),B=c(42513),C=c(92155);let D={recalculate:{en:"Recalculate",ar:"إعادة الاحتساب"},submit:{en:"Submit for review",ar:"إرسال للمراجعة"},review:{en:"Submit for approval",ar:"إرسال للاعتماد"},approve:{en:"Approve",ar:"اعتماد"},reject:{en:"Reject",ar:"رفض"},cancel:{en:"Cancel",ar:"إلغاء"},post:{en:"Post approval",ar:"ترحيل الاعتماد"},send:{en:"Send to supplier",ar:"إرسال للمورد"},partial:{en:"Mark partially supplied",ar:"توريد جزئي"},full:{en:"Mark fully supplied",ar:"توريد كامل"},close:{en:"Close",ar:"إغلاق"},"post-supply":{en:"Post supply",ar:"ترحيل التوريد"},"post-buyback":{en:"Post buyback",ar:"ترحيل شراء العميل"},reverse:{en:"Reverse posting",ar:"عكس الترحيل"}},E={recalculate:g.A,submit:h.A,review:i.A,approve:j.A,reject:k.A,cancel:l.A,post:m.A,send:n.A,partial:n.A,full:n.A,close:j.A,"post-supply":m.A,"post-buyback":m.A,reverse:o.A},F={low:{en:"Low",ar:"منخفضة"},normal:{en:"Normal",ar:"عادية"},high:{en:"High",ar:"عالية"},urgent:{en:"Urgent",ar:"عاجلة"}};function G(a){return"reject"===a||"cancel"===a||"reverse"===a}function H(){let a=(0,f.useParams)(),b=(0,f.useRouter)(),{i18n:c}=(0,s.Bd)(),{user:h}=(0,t.A)(),i=c.language.startsWith("ar")?"ar":"en",{selected:j,support:k,isLoading:l,isSubmitting:m,error:n,get:o,loadSupport:H,act:L,recalculate:M}=(0,u.PL)(),[N,O]=(0,e.useState)(!1),[P,Q]=(0,e.useState)(null),[R,S]=(0,e.useState)(""),[T,U]=(0,e.useState)(""),[V,W]=(0,e.useState)(""),[X,Y]=(0,e.useState)(null),Z=a.id,$=(0,e.useCallback)(async()=>{let a=await o(Z);a&&await H(Z,a)},[o,Z,H]),_=(0,e.useMemo)(()=>j?(0,v.e6)(j.status,(0,v.Cf)(h),j.buy_order_type):[],[j,h?.permissions]),aa=async()=>{if(P){if(G(P)&&!R.trim())return void r.o.error("ar"===i?"السبب مطلوب.":"Reason is required.");try{let a=await L(Z,P,{reason:R.trim()||void 0,receiving_vault_id:T||void 0,customer_user_id:V.trim()||void 0});a&&"object"==typeof a&&"order_no"in a&&("journal_entries"in a||"reversed_journals"in a)&&Y(a),r.o.success("ar"===i?"تم تنفيذ الإجراء.":"Action completed."),O(!1),Q(null),await $()}catch(a){r.o.error((0,u.an)(a))}}};return l&&!j?(0,d.jsx)("div",{className:"flex h-80 items-center justify-center",children:(0,d.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gold-500 border-t-transparent"})}):j?(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsx)(w.z,{title:`${"ar"===i?"أمر شراء":"Buy order"} ${j.buy_order_no}`,description:v.df[j.buy_order_type]?.[i]??j.buy_order_type,breadcrumbs:[{label:"ar"===i?"أوامر الشراء":"Buy orders",href:"/buy-orders"},{label:j.buy_order_no}],actions:(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsxs)(z.$,{variant:"outline",onClick:()=>b.push("/buy-orders"),children:[(0,d.jsx)(p.A,{className:"h-4 w-4"}),"ar"===i?"رجوع":"Back"]}),(0,d.jsx)(z.$,{variant:"outline",onClick:$,disabled:l,children:(0,d.jsx)(g.A,{className:"h-4 w-4"})}),(0,v.Cf)(h).includes("buy_orders:print")&&(0,d.jsxs)(z.$,{variant:"outline",onClick:()=>{if(!k.voucher)return void r.o.error("ar"===i?"السند غير جاهز بعد.":"Voucher is not ready yet.");try{(0,u.mL)(k.voucher,`${k.voucher.order_no}-buy-voucher`),r.o.success("ar"===i?"تم فتح عرض الطباعة.":"Voucher print view opened.")}catch(a){r.o.error((0,u.an)(a))}},children:[(0,d.jsx)(q.A,{className:"h-4 w-4"}),"ar"===i?"طباعة":"Print"]})]})}),n&&(0,d.jsx)("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700",children:n}),(0,d.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[1fr_360px]",children:[(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsx)(x.i,{title:"ar"===i?"ملخص الأمر":"Order summary",children:(0,d.jsxs)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[(0,d.jsx)(I,{label:"ar"===i?"الحالة":"Status",value:(0,d.jsx)(y.W,{tone:v.Xh[j.status]??"neutral",children:v.Td[j.status]?.[i]??j.status})}),(0,d.jsx)(I,{label:"ar"===i?"الأولوية":"Priority",value:F[j.priority]?.[i]??j.priority}),(0,d.jsx)(I,{label:"ar"===i?"المورد":"Supplier",value:j.supplier_id||"-"}),(0,d.jsx)(I,{label:"ar"===i?"العميل":"Customer",value:j.customer_id||"-"}),(0,d.jsx)(I,{label:"ar"===i?"الفرع":"Branch",value:j.target_branch_id||"-"}),(0,d.jsx)(I,{label:"ar"===i?"الخزنة":"Vault",value:j.target_vault_id||"-"}),(0,d.jsx)(I,{label:"ar"===i?"مرجع المورد":"Supplier ref",value:j.supplier_reference||"-"}),(0,d.jsx)(I,{label:"ar"===i?"مرجع خارجي":"External ref",value:j.external_reference||"-"}),(0,d.jsx)(I,{label:"ar"===i?"تم الإنشاء":"Created",value:(0,C.r6)(j.created_at)}),(0,d.jsx)(I,{label:"ar"===i?"اعتمد":"Approved",value:j.approved_at?(0,C.r6)(j.approved_at):"-"}),(0,d.jsx)(I,{label:"ar"===i?"رحل":"Posted",value:j.posted_at?(0,C.r6)(j.posted_at):"-"}),(0,d.jsx)(I,{label:"ar"===i?"أغلق":"Closed",value:j.closed_at?(0,C.r6)(j.closed_at):"-"})]})}),(0,d.jsx)(x.i,{title:"ar"===i?"بنود الذهب":"Gold items",padded:!1,children:(0,d.jsx)("div",{className:"overflow-auto",children:(0,d.jsxs)("table",{className:"w-full min-w-[760px] text-sm",children:[(0,d.jsx)("thead",{className:"border-b border-border bg-muted/40 text-left text-xs text-muted-foreground",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-4 py-3",children:"#"}),(0,d.jsx)("th",{className:"px-4 py-3",children:"ar"===i?"النوع":"Metal"}),(0,d.jsx)("th",{className:"px-4 py-3",children:"ar"===i?"الوزن":"Weight"}),(0,d.jsx)("th",{className:"px-4 py-3",children:"ar"===i?"الكمية":"Qty"}),(0,d.jsx)("th",{className:"px-4 py-3",children:"ar"===i?"سعر الجرام":"Price/g"}),(0,d.jsx)("th",{className:"px-4 py-3",children:"ar"===i?"العلاوة":"Premium"}),(0,d.jsx)("th",{className:"px-4 py-3",children:"ar"===i?"الإجمالي":"Total"})]})}),(0,d.jsxs)("tbody",{children:[(j.items??[]).map((a,b)=>(0,d.jsxs)("tr",{className:"border-b border-border/60",children:[(0,d.jsx)("td",{className:"px-4 py-3",children:b+1}),(0,d.jsx)("td",{className:"px-4 py-3",children:a.metal_type}),(0,d.jsx)("td",{className:"px-4 py-3 font-mono",children:(0,C.q0)(Number(a.weight_grams))}),(0,d.jsx)("td",{className:"px-4 py-3 font-mono",children:a.quantity}),(0,d.jsx)("td",{className:"px-4 py-3 font-mono",children:(0,C.S8)(Number(a.price_per_gram))}),(0,d.jsx)("td",{className:"px-4 py-3 font-mono",children:(0,C.S8)(Number(a.premium))}),(0,d.jsx)("td",{className:"px-4 py-3 font-mono font-semibold",children:(0,C.S8)(Number(a.line_total))})]},a.id)),(!j.items||0===j.items.length)&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:7,className:"px-4 py-8 text-center text-muted-foreground",children:"ar"===i?"لا توجد بنود.":"No items."})})]})]})})}),(0,d.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,d.jsx)(x.i,{title:"ar"===i?"سجل الحالات":"Status history",children:(0,d.jsxs)("div",{className:"space-y-2",children:[k.history.map(a=>(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 p-3 text-sm",children:[(0,d.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,d.jsxs)("strong",{children:[a.old_status||"-"," ","->"," ",a.new_status]}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,C.r6)(a.changed_at)})]}),a.note&&(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:a.note})]},a.id)),0===k.history.length&&(0,d.jsx)("p",{className:"text-sm text-muted-foreground",children:"ar"===i?"لا يوجد سجل حالات.":"No status history."})]})}),(0,d.jsx)(x.i,{title:"ar"===i?"الاعتمادات":"Approvals",children:(0,d.jsxs)("div",{className:"space-y-3",children:[k.approvals.map(a=>(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 p-3 text-sm",children:[(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("strong",{children:a.approval_type}),(0,d.jsx)(y.W,{tone:"approved"===a.status?"success":"rejected"===a.status?"danger":"pending",children:a.status})]}),(0,d.jsx)("div",{className:"mt-2 space-y-1",children:(a.steps??[]).map(a=>(0,d.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,d.jsxs)("span",{children:["Step ",a.step_order]}),(0,d.jsx)("span",{children:a.status})]},a.id))})]},a.id)),0===k.approvals.length&&(0,d.jsx)("p",{className:"text-sm text-muted-foreground",children:"ar"===i?"لا توجد طلبات اعتماد.":"No approval requests."})]})})]}),(0,d.jsx)(x.i,{title:"ar"===i?"نتائج الترحيل":"Posting results",children:(0,d.jsx)(K,{result:X||k.postings,language:i})})]}),(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsx)(x.i,{title:"ar"===i?"الملخص المالي":"Financial summary",children:(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)(J,{label:"ar"===i?"الإجمالي الفرعي":"Subtotal",value:j.subtotal_amount}),(0,d.jsx)(J,{label:"ar"===i?"الرسوم":"Fees",value:j.fee_amount}),(0,d.jsx)(J,{label:"ar"===i?"الضريبة":"Tax",value:j.tax_amount}),(0,d.jsx)(J,{label:"ar"===i?"الخصم":"Discount",value:j.discount_amount}),(0,d.jsx)("div",{className:"border-t border-border pt-3",children:(0,d.jsx)(J,{label:"ar"===i?"الإجمالي":"Total",value:j.total_amount,strong:!0})})]})}),(0,d.jsx)(x.i,{title:"ar"===i?"إجراءات سير العمل":"Workflow actions",children:(0,d.jsx)("div",{className:"grid gap-2",children:0===_.length?(0,d.jsx)("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:"ar"===i?"لا توجد إجراءات متاحة.":"No available actions."}):_.map(a=>{let b=E[a];return(0,d.jsxs)(z.$,{variant:"reject"===a||"cancel"===a||"reverse"===a?"outline":"primary",onClick:()=>(a=>{if("recalculate"===a)return void M(Z).then(()=>{r.o.success("ar"===i?"تمت إعادة الاحتساب.":"Order recalculated."),$()}).catch(a=>r.o.error((0,u.an)(a)));Q(a),S(""),U(j?.target_vault_id||""),W(""),O(!0)})(a),disabled:m,children:[(0,d.jsx)(b,{className:"h-4 w-4"}),D[a][i]]},a)})})}),(0,d.jsx)(x.i,{title:"ar"===i?"سجلات التدقيق":"Audit logs",children:(0,d.jsxs)("div",{className:"max-h-[360px] space-y-2 overflow-auto pr-1",children:[k.auditLogs.map((a,b)=>(0,d.jsx)("div",{className:"rounded-lg border border-border bg-muted/20 p-3 text-xs",children:(0,d.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,d.jsx)("strong",{children:String(a.action||"audit").replace(/_/g," ").toUpperCase()}),(0,d.jsx)("span",{className:"text-muted-foreground",children:(0,C.r6)(a.created_at)})]})},a.id||b)),0===k.auditLogs.length&&(0,d.jsx)("p",{className:"text-sm text-muted-foreground",children:"ar"===i?"لا توجد سجلات تدقيق.":"No audit logs."})]})})]})]}),(0,d.jsx)(A.a,{open:N,onClose:()=>O(!1),title:P?D[P][i]:"",size:"sm",children:(0,d.jsxs)("div",{className:"space-y-4",children:["post-supply"===P&&(0,d.jsx)(B.FO,{id:"receiving_vault_id",name:"receiving_vault_id",label:"ar"===i?"خزنة الاستلام":"Receiving vault ID",value:T,onChange:a=>U(a.target.value)}),"post-buyback"===P&&(0,d.jsx)("div",{className:"rounded-lg border border-border bg-muted/30 p-3 text-sm text-muted-foreground",children:"ar"===i?"سيتم استخدام العميل المرتبط بأمر الشراء تلقائياً. لا تحتاج لإدخال معرف يدوي.":"The customer linked to this buy order will be used automatically. No manual ID is required."}),(0,d.jsx)(B.l2,{id:"reason",name:"reason",label:G(P)?"ar"===i?"السبب":"Reason":"ar"===i?"ملاحظة":"Note",value:R,rows:4,onChange:a=>S(a.target.value),required:G(P)}),(0,d.jsxs)("div",{className:"flex justify-end gap-2 border-t border-border pt-4",children:[(0,d.jsx)(z.$,{variant:"outline",onClick:()=>O(!1),children:"ar"===i?"إغلاق":"Close"}),(0,d.jsx)(z.$,{variant:"reject"===P||"cancel"===P||"reverse"===P?"danger":"primary",onClick:aa,isLoading:m,children:P?D[P][i]:"ar"===i?"تأكيد":"Confirm"})]})]})})]}):(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)(z.$,{variant:"outline",onClick:()=>b.push("/buy-orders"),children:[(0,d.jsx)(p.A,{className:"h-4 w-4"}),"ar"===i?"رجوع":"Back"]}),(0,d.jsx)("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-700",children:n||("ar"===i?"لم يتم العثور على أمر الشراء.":"Buy order was not found.")})]})}function I({label:a,value:b}){return(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:a}),(0,d.jsx)("div",{className:"mt-1 text-sm font-medium",children:b})]})}function J({label:a,value:b,strong:c}){return(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:a}),(0,d.jsx)("span",{className:`font-mono tabular-nums ${c?"text-lg font-bold":"font-semibold"}`,children:(0,C.S8)(Number(b||0))})]})}function K({result:a,language:b}){if(!a)return(0,d.jsx)("p",{className:"text-sm text-muted-foreground",children:"ar"===b?"لم يتم إنشاء ترحيلات بعد.":"No posting records yet."});let c=a.journal_entries??[],e=a.reversed_journals??[],f=a.gold_postings??[],g=a.cash_postings??[];return(0,d.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,d.jsx)(L,{title:"ar"===b?"قيود اليومية":"Journal entries",rows:c,empty:"ar"===b?"لا توجد قيود.":"No journals."}),(0,d.jsx)(L,{title:"ar"===b?"القيود المعكوسة":"Reversals",rows:e,empty:"ar"===b?"لا توجد قيود معكوسة.":"No reversals."}),(0,d.jsx)(L,{title:"ar"===b?"حركات الذهب":"Gold postings",rows:f,empty:"ar"===b?"لا توجد حركات ذهب.":"No gold postings."}),(0,d.jsx)(L,{title:"ar"===b?"حركات النقد":"Cash postings",rows:g,empty:"ar"===b?"لا توجد حركات نقدية.":"No cash postings."})]})}function L({title:a,rows:b,empty:c}){return(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 p-3",children:[(0,d.jsx)("p",{className:"mb-2 text-sm font-semibold",children:a}),b.length?(0,d.jsx)("ul",{className:"space-y-2",children:b.map((a,b)=>(0,d.jsx)("li",{className:"rounded bg-background p-2 text-xs text-muted-foreground",children:Object.entries(a).slice(0,4).map(([a,b])=>(0,d.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,d.jsx)("span",{children:a}),(0,d.jsx)("span",{className:"font-mono text-right",children:String(b??"-")})]},a))},b))}):(0,d.jsx)("p",{className:"text-xs text-muted-foreground",children:c})]})}},91292:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(23339).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},91645:a=>{"use strict";a.exports=require("net")},94735:a=>{"use strict";a.exports=require("events")},95360:(a,b,c)=>{"use strict";c.d(b,{i:()=>f});var d=c(21124),e=c(44943);function f({title:a,description:b,actions:c,icon:f,children:g,className:h,bodyClassName:i,footer:j,padded:k=!0}){return(0,d.jsxs)("section",{className:(0,e.cn)("rounded-xl border border-border bg-card overflow-hidden",h),children:[(a||c)&&(0,d.jsxs)("header",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[f,(0,d.jsxs)("div",{className:"min-w-0",children:[a&&(0,d.jsx)("h3",{className:"text-[14.5px] font-semibold text-foreground truncate",children:a}),b&&(0,d.jsx)("p",{className:"text-[12px] text-muted-foreground truncate",children:b})]})]}),c&&(0,d.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:c})]}),(0,d.jsx)("div",{className:(0,e.cn)(k&&"p-5",i),children:g}),j&&(0,d.jsx)("div",{className:"px-5 py-3 border-t border-border bg-muted/30",children:j})]})}}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[8543,5471,3852,3991,6802,1866,3626,7574,9545],()=>b(b.s=54450));module.exports=c})();