1import{a as K}from"./chunk-4XTOUKLX.js";import{a as U,b as L}from"./chunk-TNBEB5LT.js";import{a as O}from"./chunk-WSFU6SFG.js";import"./chunk-PJU3RY6S.js";import{a as z}from"./chunk-A5M5H5PX.js";import{C as D,D as R,E as N,b as B,c as P,e as _,g as E,h as A,l as I,n as T,p as V,s as M}from"./chunk-T3OC74ZZ.js";import"./chunk-NAOEBZYB.js";import"./chunk-K2BAHOWP.js";import"./chunk-4QTHKBSW.js";import{m as F,w as y}from"./chunk-EQ6PZGEX.js";import{Eb as c,Nb as r,Ob as o,Pb as s,Tb as h,Yb as u,Zb as m,ab as x,gb as d,ic as w,jc as a,kc as C,lb as v,lc as b,na as p,oa as g,sb as k,sc as S,xb as f}from"./chunk-QZFOZYL5.js";import{h as H}from"./chunk-SZAW6ZBW.js";var j=H(K());var W=()=>[5,10,25,50];function $(l,n){if(l&1){let e=h();r(0,"div",40),s(1,"img",41),r(2,"button",9),u("click",function(){p(e);let t=m(3);return g(t.removeFile())}),s(3,"i",42),o()()}if(l&2){let e=m(3);d(),c("src",e.filePreview,x)}}function J(l,n){if(l&1){let e=h();r(0,"div",40),s(1,"i",43),r(2,"div")(3,"div",44),a(4),o(),r(5,"small",45),a(6),o()(),r(7,"button",46),u("click",function(){p(e);let t=m(3);return g(t.removeFile())}),s(8,"i",47),o()()}if(l&2){let e=m(3);d(4),C(e.selectedFile.name),d(2),b("",(e.selectedFile.size/1024/1024).toFixed(2)," MB")}}function Q(l,n){if(l&1&&(r(0,"div",38),f(1,$,4,1,"div",39)(2,J,9,2,"div",39),o()),l&2){let e=m(2);d(),c("ngIf",e.filePreview&&e.filePreview.startsWith("data:image")),d(),c("ngIf",e.selectedFile&&e.selectedFile.type==="application/pdf")}}function X(l,n){l&1&&(r(0,"div",48),s(1,"i",49),a(2," Please upload a document. "),o())}function Y(l,n){if(l&1&&s(0,"ckeditor",50),l&2){let e=m(2);c("editor",e.Editor)}}function Z(l,n){l&1&&(r(0,"div",51),s(1,"i",49),a(2," Description is required and must be at least 10 characters long. "),o())}function ee(l,n){l&1&&s(0,"i",52)}function te(l,n){if(l&1){let e=h();r(0,"div",3),u("click",function(){p(e);let t=m();return g(t.closeModal())}),r(1,"div",4),u("click",function(t){return p(e),g(t.stopPropagation())}),r(2,"div",5)(3,"div",6)(4,"h5",7),s(5,"i",8),a(6),o(),r(7,"button",9),u("click",function(){p(e);let t=m();return g(t.closeModal())}),s(8,"i",10),o()(),r(9,"div",11)(10,"form",12),u("ngSubmit",function(){p(e);let t=m();return g(t.onSubmit())}),r(11,"div")(12,"label",13),a(13," Upload Document "),o(),r(14,"div",14),u("click",function(){p(e);let t=w(16);return g(t.click())}),r(15,"input",15,0),u("change",function(t){p(e);let q=m();return g(q.onFileSelected(t))}),o(),s(17,"i",16),r(18,"p",17),a(19,"Click to upload or drag & drop"),o(),r(20,"p",18),a(21,"PDF, PNG, JPG up to 10MB"),o()(),f(22,Q,3,2,"div",19)(23,X,3,0,"div",20),o(),r(24,"div")(25,"label",21),a(26," Description "),r(27,"span",22),a(28,"*"),o()(),f(29,Y,1,1,"ckeditor",23)(30,Z,3,0,"div",24),o(),r(31,"div",25),s(32,"input",26),r(33,"label",27),a(34,"Show PDF File?"),o()(),r(35,"div")(36,"label",13),a(37,"Status "),r(38,"span",22),a(39,"*"),o()(),r(40,"div",28)(41,"div",29),s(42,"input",30),r(43,"label",31),a(44,"Active"),o()(),r(45,"div",29),s(46,"input",32),r(47,"label",33),a(48,"Inactive"),o()()()()()(),r(49,"div",34)(50,"button",35),u("click",function(){p(e);let t=m();return g(t.closeModal())}),a(51,"Cancel"),o(),r(52,"button",36),u("click",function(){p(e);let t=m();return g(t.onSubmit())}),f(53,ee,1,0,"i",37),a(54),o()()()()()}if(l&2){let e,i,t=m();d(6),b(" ",t.isEditMode?"Edit Bunkering Record":"Add Bunkering Record"," "),d(4),c("formGroup",t.bunkeringForm),d(12),c("ngIf",t.filePreview||t.selectedFile),d(),c("ngIf",((e=t.bunkeringForm.get("document"))==null?null:e.invalid)&&((e=t.bunkeringForm.get("document"))==null?null:e.touched)),d(6),c("ngIf",t.bunkeringForm&&t.Editor),d(),c("ngIf",((i=t.bunkeringForm.get("description"))==null?null:i.invalid)&&((i=t.bunkeringForm.get("description"))==null?null:i.touched)),d(22),c("disabled",t.bunkeringForm.invalid||t.isSubmitting),d(),c("ngIf",t.isSubmitting),d(),b(" ",t.isSubmitting?"Saving...":t.isEditMode?"Update Record":"Add Record"," ")}}var G=class l{constructor(n,e){this.fb=n;this.service=e;this.bunkeringForm=this.fb.group({document:[""],description:["",[_.required,_.minLength(10)]],showPdf:[!1],status:["active",_.required]})}Editor=j.default;columns=[];data=[];totalRecords=0;isLoading=!1;filterOptions={};rowActions=[];showModal=!1;
1isEditMode=!1;isSubmitting=!1;bunkeringForm;editingId=null;selectedFile=null;filePreview=null;existingFilePath=null;ngOnInit(){this.initColumns(),this.initFilters(),this.initActions(),this.loadData()}initColumns(){this.columns=[{key:"sno",label:"S.No",type:"number",align:"center",width:"80px"},{key:"documentUrl",label:"Document",type:"text",width:"250px"},{key:"description",label:"Description",type:"text",width:"350px"},{key:"showPdf",label:"Show PDF?",type:"boolean",width:"120px",align:"center"},{key:"status",label:"Status",type:"status",width:"120px",align:"center",statusConfig:{active:{label:"Active",backgroundColor:"#1B5E20",color:"#fff"},inactive:{label:"Inactive",backgroundColor:"#dc3545",color:"#fff"}}}]}initFilters(){this.filterOptions={status:["active","inactive"]}}initActions(){this.rowActions=[{icon:"edit",tooltip:"Edit",color:"#0A3C7D",onClick:n=>this.editItem(n)},{icon:"delete",tooltip:"Delete",color:"#dc3545",onClick:n=>this.deleteItem(n.id)}]}loadData(){this.isLoading=!0,this.service.getAllBunkeringRecords().subscribe({next:n=>{let e=n?.data||n;this.data=e.map((i,t)=>({id:i.id,sno:t+1,documentUrl:i.filePath,description:i.description,showPdf:!!i.showPdf,status:i.isActive?"active":"inactive",createdAt:i.createdAt,createdBy:i.createdBy,lastUpdated:i.updatedAt})),this.totalRecords=this.data.length,this.isLoading=!1},error:n=>{console.error("Error fetching bunkering records:",n),this.isLoading=!1}})}onFileSelected(n){let e=n.target.files[0];if(e)if(this.selectedFile=e,this.bunkeringForm.patchValue({document:e}),e.type.startsWith("image/")){let i=new FileReader;i.onload=t=>this.filePreview=t.target?.result,i.readAsDataURL(e)}else this.filePreview=null}removeFile(){this.selectedFile=null,this.filePreview=null,this.existingFilePath=null,this.bunkeringForm.patchValue({document:null})}onAddNew(){this.isEditMode=!1,this.editingId=null,this.selectedFile=null,this.filePreview=null,this.existingFilePath=null,this.bunkeringForm.reset({document:null,description:"",showPdf:!1,status:"active"}),this.showModal=!0}editItem(n){this.isEditMode=!0,this.editingId=n.id,this.showModal=!0,this.bunkeringForm.patchValue({description:n.description,showPdf:n.showPdf,status:n.status,document:null}),this.existingFilePath=n.documentUrl}onSubmit(){if(this.bunkeringForm.invalid){this.bunkeringForm.markAllAsTouched();return}this.isSubmitting=!0;let n=this.bunkeringForm.value,e=new FormData;e.append("description",n.description),e.append("showPdf",n.showPdf?"1":"0"),e.append("publish","1"),e.append("isActive",n.status==="active"?"1":"0"),this.selectedFile?e.append("filePath",this.selectedFile):this.existingFilePath&&e.append("filePath",this.existingFilePath),(this.isEditMode&&this.editingId?this.service.updateBunkeringRecord(this.editingId,e):this.service.addBunkeringRecord(e)).subscribe({next:()=>{this.isSubmitting=!1,this.closeModal(),this.loadData()},error:t=>{console.error("Error saving bunkering record:",t),this.isSubmitting=!1}})}deleteItem(n){confirm("Are you sure you want to delete this record?")&&this.service.deleteBunkeringRecord(n).subscribe({next:()=>this.loadData(),error:e=>console.error("Error deleting record:",e)})}closeModal(){this.showModal=!1,this.isEditMode=!1,this.editingId=null,this.selectedFile=null,this.filePreview=null,this.existingFilePath=null,this.bunkeringForm.reset({document:null,description:"",showPdf:!1,status:"active"})}static \u0275fac=function(e){return new(e||l)(v(D),v(z))};static \u0275cmp=k({type:l,selectors:[["app-bunkering"]],decls:2,vars:19,consts:[["fileInput",""],[3,"addNew","displayedColumns","dataSource","totalRecords","pageSize","pageSizeOptions","isLoading","showSearch","showFilter","showAddButton","addButtonText","tableTitle","searchPlaceholder","filterOptions","rowActions","selectable","stickyHeader","stickyFooter"],["class","modal fade show d-block bg-dark bg-opacity-75","tabindex","-1","role","dialog","aria-labelledby","bunkeringModalTitle","style","background-color: rgba(0, 0, 0, 0.8); z-index: 2000;",3,"click",4,"ngIf"],["tabindex","-1","role","dialog","aria-labelledby","bunkeringModalTitle",1,"modal","fade","show","d-block","bg-dark","bg-opacity-75",2,"background-color","rgba(0, 0, 0, 0.8)","z-index","2000",3,"click"],["role","document",1,"modal-dialog","modal
1-dialog-centered","modal-lg",2,"z-index","2050",3,"click"],[1,"modal-content","border-0","shadow-lg","rounded-4","overflow-hidden",2,"z-index","2100","background-color","#ffffff"],[1,"modal-header","text-white","d-flex","align-items-center","justify-content-between","px-4","py-3",2,"background-color","#13296C","box-shadow","0 2px 8px rgba(0,0,0,0.3)"],["id","bunkeringModalTitle",1,"modal-title","fw-bold","d-flex","align-items-center","gap-2","mb-0"],[1,"ri-gas-station-line","fs-4","text-light"],["type","button",1,"btn","btn-light","btn-sm","rounded-circle","p-0","d-flex","align-items-center","justify-content-center","border-0","shadow-sm",2,"width","36px","height","36px",3,"click"],[1,"ri-close-line","fs-5",2,"color","#0B1941"],[1,"modal-body","p-4","bg-white"],[1,"d-flex","flex-column","gap-4",3,"ngSubmit","formGroup"],[1,"form-label","fw-semibold","text-dark"],[1,"border","border-2","border-dashed","rounded-3","text-center","bg-light","p-4",2,"cursor","pointer",3,"click"],["type","file","accept","application/pdf,image/*","hidden","",3,"change"],[1,"ri-upload-cloud-line","fs-1","text-primary","mb-2"],[1,"fw-semibold","mb-1"],[1,"text-muted","small"],["class","border rounded-3 p-3 mt-3 bg-white shadow-sm",4,"ngIf"],["class","text-danger small mt-2",4,"ngIf"],["for","description",1,"form-label","fw-semibold","text-dark"],[1,"text-danger"],["id","description","formControlName","description",3,"editor",4,"ngIf"],["class","text-danger small mt-1",4,"ngIf"],[1,"form-check","form-switch","mt-3"],["name","showPdf","type","checkbox","id","showPdf","formControlName","showPdf",1,"form-check-input"],["for","showPdf",1,"form-check-label","fw-semibold"],[1,"d-flex","align-items-center","gap-4","mt-2"],[1,"form-check"],["name","status","type","radio","formControlName","status","id","active","value","active",1,"form-check-input",2,"accent-color","#2947A3"],["for","active",1,"form-check-label","fw-semibold"],["name","status","type","radio","formControlName","status","id","inactive","value","inactive",1,"form-check-input",2,"accent-color","#2947A3"],["for","inactive",1,"form-check-label","fw-semibold"],[1,"modal-footer","bg-light","d-flex","justify-content-end","gap-3","py-3","px-4","border-top"],["type","button",1,"btn","btn-outline-secondary","px-4",3,"click"],["type","submit",1,"btn","text-white","px-4","border-0",2,"background","linear-gradient(135deg,#2947A3,#13296C)",3,"click","disabled"],["class","ri-loader-4-line spin",4,"ngIf"],[1,"border","rounded-3","p-3","mt-3","bg-white","shadow-sm"],["class","d-flex align-items-center gap-3",4,"ngIf"],[1,"d-flex","align-items-center","gap-3"],["alt","",1,"rounded-2",2,"max-width","120px","max-height","100px","object-fit","cover",3,"src"],[1,"ri-close-line","fs-5","text-dark"],[1,"ri-file-pdf-line","fs-3","text-danger"],[1,"fw-semibold"],[1,"text-muted"],["type","button",1,"btn","btn-sm","btn-outline-danger","rounded-circle","ms-auto",3,"click"],[1,"ri-close-line"],[1,"text-danger","small","mt-2"],[1,"ri-error-warning-line"],["id","description","formControlName","description",3,"editor"],[1,"text-danger","small","mt-1"],[1,"ri-loader-4-line","spin"]],template:function(e,i){e&1&&(r(0,"app-common-table",1),u("addNew",function(){return i.onAddNew()}),o(),f(1,te,55,9,"div",2)),e&2&&(c("displayedColumns",i.columns)("dataSource",i.data)("totalRecords",i.totalRecords)("pageSize",10)("pageSizeOptions",S(18,W))("isLoading",i.isLoading)("showSearch",!0)("showFilter",!0)("showAddButton",!0)("addButtonText","Add Bunkering Record")("tableTitle","24*7 Bunkering Management")("searchPlaceholder","Search bunkering records...")("filterOptions",i.filterOptions)("rowActions",i.rowActions)("selectable",!1)("stickyHeader",!0)("stickyFooter",!0),d(),c("ngIf",i.showModal))},dependencies:[y,F,R,I,P,B,T,E,A,N,V,M,L,U,O],encapsulation:2})};export{G as BunkeringComponent};
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.