oceanhelm 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- (function(V,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(V=typeof globalThis<"u"?globalThis:V||self,e(V.OceanHelm={},V.Vue))})(this,function(V,e){"use strict";const ym="",F=(o,t)=>{const r=o.__vccOpts||o;for(const[l,i]of t)r[l]=i;return r},O={name:"ConfigurableSidebar",props:{brandName:{type:String,default:"OceanHelm"},logoIcon:{type:String,default:"bi bi-water"},showLogo:{type:Boolean,default:!0},menuItems:{type:Array,required:!0,default:()=>[]},userProfile:{type:Object,default:()=>({})},responsive:{type:Boolean,default:!0},customClasses:{type:String,default:""},permissionChecker:{type:Function,default:null}},computed:{sidebarClasses(){return this.customClasses},filteredMenuItems(){return this.menuItems.filter(o=>this.hasPermission(o)?o.type==="dropdown"&&o.children?o.children.some(t=>this.hasPermission(t)):!0:!1)}},mounted(){this.responsive&&this.initializeResponsiveBehavior()},methods:{toggleDropdown(o){this.filteredMenuItems.forEach(t=>{t!==o&&t.type==="dropdown"&&(t.open=!1)}),o.open=!o.open},getFilteredChildren(o){return o.children?o.children.filter(t=>this.hasPermission(t)):[]},hasPermission(o){return this.permissionChecker?this.permissionChecker(o,this.userProfile):!o.roles||o.roles.length===0?!0:o.roles.includes(this.userProfile.role)},handleNavigation(o){var t;this.$emit("navigate",o),o.href&&!o.preventDefault&&(o.external?window.open(o.href,"_blank"):(t=this.$router)==null||t.push(o.href))},handleAction(o){this.$emit("action",o)},handleItemClick(o){this.$emit("item-click",o),o.type},initializeResponsiveBehavior(){const o=document.getElementById("sidebarToggle"),t=document.getElementById("sidebar"),r=document.getElementById("content");!o||!t||!r||(window.innerWidth>=768&&(t.classList.toggle("active"),r.classList.toggle("active")),o.addEventListener("click",()=>{t.classList.toggle("active"),r.classList.toggle("active")}),document.addEventListener("click",l=>{const i=t.contains(l.target),s=o.contains(l.target);!i&&!s&&window.innerWidth<768&&t.classList.contains("active")&&(t.classList.remove("active"),r.classList.remove("active"))}))}},emits:["navigate","action","item-click"]},U={key:0,class:"logo d-flex align-items-center left"},j={style:{"margin-left":"45px"}},G={class:"list-unstyled components mt-4"},H=["onClick"],W=["href","onClick"],Q=["onClick"],J=["onClick"],Y={class:"sidebar-dropdown"},Z=["onClick"],K={key:3,class:"dropdown-divider"},$={key:4};function X(o,t,r,l,i,s){return e.openBlock(),e.createElementBlock("nav",{id:"sidebar",class:e.normalizeClass(s.sidebarClasses)},[r.showLogo?(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("span",j,e.toDisplayString(r.brandName),1)])):e.createCommentVNode("",!0),e.createElementVNode("ul",G,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.filteredMenuItems,(n,a)=>(e.openBlock(),e.createElementBlock("li",{key:a,class:e.normalizeClass({active:n.active,dropdown:n.type==="dropdown"}),onClick:c=>s.handleItemClick(n)},[n.type==="link"?(e.openBlock(),e.createElementBlock("a",{key:0,href:n.href||"#",onClick:e.withModifiers(c=>s.handleNavigation(n),["prevent"])},[n.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(n.icon)},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(n.label),1)],8,W)):n.type==="button"?(e.openBlock(),e.createElementBlock("a",{key:1,onClick:e.withModifiers(c=>s.handleAction(n),["prevent"]),style:{cursor:"pointer"}},[n.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(n.icon)},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(n.label),1)],8,Q)):n.type==="dropdown"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("a",{class:"dropdown-toggle",onClick:e.withModifiers(c=>s.toggleDropdown(n),["prevent"]),style:{cursor:"pointer"}},[n.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(n.icon)},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(n.label)+" ",1),e.createElementVNode("i",{class:e.normalizeClass(["",{open:n.open}])},null,2)],8,J),e.withDirectives(e.createElementVNode("ul",Y,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.getFilteredChildren(n),(c,y)=>(e.openBlock(),e.createElementBlock("li",{key:y},[e.createElementVNode("a",{class:"dropdown-item",onClick:e.withModifiers(w=>s.handleAction(c),["prevent"])},e.toDisplayString(c.label),9,Z)]))),128))],512),[[e.vShow,n.open]])],64)):n.type==="separator"?(e.openBlock(),e.createElementBlock("div",K)):n.type==="text"?(e.openBlock(),e.createElementBlock("a",$,e.toDisplayString(n.label),1)):e.createCommentVNode("",!0)],10,H))),128))]),e.renderSlot(o.$slots,"footer")],2)}const R=F(O,[["render",X]]),Em="",v={name:"VesselList",props:{vessels:{type:Array,required:!0,default:()=>[]},userProfile:{type:Object,required:!0,default:()=>({role:"viewer",vessel:null})},loading:{type:Boolean,default:!1},currentRoute:{type:String,default:"dashboard"},config:{type:Object,default:()=>({enableAdd:!0,enableEdit:!0,enableDelete:!0,enableStatusToggle:!0,showCertifications:!0})}},data(){return{activeFilter:"All"}},emits:["vessel-add","vessel-click","vessel-edit","vessel-delete","vessel-toggle-status","vessel-navigate","access-denied","date-change"],computed:{activeVesselsCount(){return this.vessels.filter(o=>o.status==="Active").length},inactiveVesselsCount(){return this.vessels.filter(o=>o.status==="Inactive").length},filteredVessels(){return this.activeFilter==="All"?this.vessels:this.vessels.filter(o=>o.status===this.activeFilter)},canAddVessel(){return this.config.enableAdd&&(this.userProfile.role==="owner"||this.userProfile.role==="staff")}},methods:{filterVessels(o){this.activeFilter=o},clearFilter(){this.activeFilter="All"},handleAddVessel(){if(!this.canAddVessel){this.handleAccessDenied("add vessel");return}this.$emit("vessel-add")},handleVesselClick(o){const t={vessel:o,route:this.currentRoute,id:o.registrationNumber,name:o.name};this.grantAccess(o)?this.currentRoute==="dashboard"?this.$emit("vessel-click",o):this.$emit("vessel-navigate",t):this.handleAccessDenied("this protected route")},handleDeleteVessel(o){if(!this.grantAccess(o)){this.handleAccessDenied("delete vessel");return}this.config.enableDelete&&this.$emit("vessel-delete",o)},handleToggleStatus(o){if(!this.grantAccess(o)){this.handleAccessDenied("change vessel status");return}this.config.enableStatusToggle&&this.$emit("vessel-toggle-status",o)},handleEditVessel(o){if(!this.grantAccess(o)){this.handleAccessDenied("edit vessel");return}this.config.enableEdit&&this.$emit("vessel-edit",o)},handleAccessDenied(o){this.$emit("access-denied",{action:o,userProfile:this.userProfile})},statusClass(o){return`status-${(o==null?void 0:o.toLowerCase())||""}`},getDuration(o,t){const r=new Date,l=new Date(o),i=r-l;if(i<0)return"Invalid (future date)";const s=Math.floor(i/(1e3*60*60)),n=Math.floor(s/24),a=s%24;let c="";return n>0&&(c+=`${n} day${n>1?"s":""}`),a>0&&(c+=(c?" ":"")+`${a} hr${a>1?"s":""}`),c||"0 hr"},setVesselDate(o){this.$emit("date-change",o)},grantAccess(o){const{role:t,vessel:r}=this.userProfile;return t==="owner"||t==="staff"||t==="captain"&&r===o.name},getDaysToExpiry(o){if(!o)return null;const t=new Date,l=new Date(o)-t;return Math.ceil(l/(1e3*60*60*24))},getExpiryClass(o){const t=this.getDaysToExpiry(o);return t===null?"":t<30?"cert-critical":t<90?"cert-warning":""}}},ee={class:"row mb-3"},te={class:"col-md-4"},oe={class:"card-body d-flex align-items-center"},ne={class:"mt-2 mb-0"},ie={class:"col-md-4"},se={class:"card-body d-flex align-items-center"},le={class:"mt-2 mb-0"},re={key:0,class:"col-md-4"},ae={class:"d-flex justify-content-between align-items-center mb-4"},de={key:0,class:"alert alert-info mb-3",role:"alert"},ce={key:1,class:"text-center py-4"},me={key:2,class:"alert alert-primary",role:"alert"},pe={key:3,class:"alert alert-warning",role:"alert"},fe={class:"alert-heading"},he={class:"mb-0"},ge={key:4,class:"row"},ye=["onClick"],Ee={class:"card-body d-flex align-items-center"},Ne={class:"flex-grow-1"},be={class:"d-flex justify-content-between align-items-center mb-2"},Ve={class:"card-title mb-0"},ke={class:"row"},we={class:"col-6"},Ce={class:"mb-0"},De={key:0,class:"col-6"},_e={class:"mb-0"},Se={class:"mb-0"},Fe={key:1,class:"col-6"},ue={class:"text-muted"},Be=["onClick"],xe={class:"action-icon v-left delete"},Te=["onClick"],Re=["onClick"];function Ae(o,t,r,l,i,s){return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ee,[e.createElementVNode("div",te,[e.createElementVNode("div",{class:e.normalizeClass(["card border-0 shadow-sm",{"border-primary border-2":i.activeFilter==="Active"}]),onClick:t[0]||(t[0]=n=>s.filterVessels("Active")),style:{cursor:"pointer"}},[e.createElementVNode("div",oe,[t[5]||(t[5]=e.createElementVNode("div",{class:"rounded-circle bg-primary bg-opacity-10 p-3 me-3"},[e.createElementVNode("i",{class:"bi bi-check-circle-fill text-primary fs-4"})],-1)),e.createElementVNode("div",null,[t[4]||(t[4]=e.createElementVNode("h6",{class:"mb-0"},"Active Vessels",-1)),e.createElementVNode("h3",ne,e.toDisplayString(s.activeVesselsCount),1)])])],2)]),e.createElementVNode("div",ie,[e.createElementVNode("div",{class:e.normalizeClass(["card border-0 shadow-sm",{"border-secondary border-2":i.activeFilter==="Inactive"}]),onClick:t[1]||(t[1]=n=>s.filterVessels("Inactive")),style:{cursor:"pointer"}},[e.createElementVNode("div",se,[t[7]||(t[7]=e.createElementVNode("div",{class:"rounded-circle bg-secondary bg-opacity-10 p-3 me-3"},[e.createElementVNode("i",{class:"bi bi-pause-circle-fill text-secondary fs-4"})],-1)),e.createElementVNode("div",null,[t[6]||(t[6]=e.createElementVNode("h6",{class:"mb-0"},"Inactive",-1)),e.createElementVNode("h3",le,e.toDisplayString(s.inactiveVesselsCount),1)])])],2)]),s.canAddVessel?(e.openBlock(),e.createElementBlock("div",re,[e.createElementVNode("div",{class:"card border-0 shadow-sm",onClick:t[2]||(t[2]=(...n)=>s.handleAddVessel&&s.handleAddVessel(...n)),style:{cursor:"pointer"}},t[8]||(t[8]=[e.createElementVNode("div",{class:"card-body d-flex align-items-center"},[e.createElementVNode("div",{class:"rounded-circle bg-success bg-opacity-10 p-3 me-3"},[e.createElementVNode("i",{class:"bi bi-patch-plus-fill text-success fs-4"})]),e.createElementVNode("div",null,[e.createElementVNode("h6",{class:"mb-0"},"Add New Vessel")])],-1)]))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",ae,[t[10]||(t[10]=e.createElementVNode("h4",{class:"mb-0"},[e.createElementVNode("i",{class:"bi bi-ship me-2"}),e.createTextVNode("Registered Vessels")],-1)),i.activeFilter!=="All"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-sm btn-outline-secondary",onClick:t[3]||(t[3]=(...n)=>s.clearFilter&&s.clearFilter(...n))},t[9]||(t[9]=[e.createElementVNode("i",{class:"bi bi-x-circle me-1"},null,-1),e.createTextVNode("Clear Filter ",-1)]))):e.createCommentVNode("",!0)]),i.activeFilter!=="All"?(e.openBlock(),e.createElementBlock("div",de,[t[11]||(t[11]=e.createTextVNode(" Showing ",-1)),e.createElementVNode("strong",null,e.toDisplayString(i.activeFilter),1),e.createTextVNode(" vessels ("+e.toDisplayString(s.filteredVessels.length)+") ",1)])):e.createCommentVNode("",!0),r.loading?(e.openBlock(),e.createElementBlock("div",ce,t[12]||(t[12]=[e.createElementVNode("div",{class:"spinner-border text-primary",role:"status"},[e.createElementVNode("span",{class:"visually-hidden"},"Loading...")],-1),e.createElementVNode("p",{class:"mt-2"},"Loading vessels...",-1)]))):!s.filteredVessels.length&&i.activeFilter==="All"?(e.openBlock(),e.createElementBlock("div",me,t[13]||(t[13]=[e.createElementVNode("h4",{class:"alert-heading"},"Empty Fleet!",-1),e.createElementVNode("p",null,"You have an empty fleet, you have not added any vessel yet.",-1),e.createElementVNode("hr",null,null,-1),e.createElementVNode("p",{class:"mb-0"},"Click on the add vessel button above, to start adding vessels to your fleet",-1)]))):!s.filteredVessels.length&&i.activeFilter!=="All"?(e.openBlock(),e.createElementBlock("div",pe,[e.createElementVNode("h4",fe,"No "+e.toDisplayString(i.activeFilter)+" Vessels",1),e.createElementVNode("p",he,"There are no "+e.toDisplayString(i.activeFilter.toLowerCase())+" vessels in your fleet.",1)])):(e.openBlock(),e.createElementBlock("div",ge,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.filteredVessels,n=>(e.openBlock(),e.createElementBlock("div",{class:"col-lg-6",key:n.registrationNumber||n.id},[e.createElementVNode("div",{class:"vessel-card",onClick:a=>s.handleVesselClick(n)},[e.createElementVNode("div",Ee,[t[17]||(t[17]=e.createElementVNode("div",{class:"vessel-icon v-left"},[e.createElementVNode("i",{class:"fas fa-ship"})],-1)),e.createElementVNode("div",Ne,[e.createElementVNode("div",be,[e.createElementVNode("h5",Ve,e.toDisplayString(n.name),1),e.createElementVNode("span",{class:e.normalizeClass(["vessel-status",s.statusClass(n.status)])},e.toDisplayString(n.status),3)]),e.createElementVNode("div",ke,[e.createElementVNode("div",we,[t[14]||(t[14]=e.createElementVNode("small",{class:"text-muted"},"Registration #:",-1)),e.createElementVNode("p",Ce,e.toDisplayString(n.registrationNumber),1)]),n.date?(e.openBlock(),e.createElementBlock("div",De,[n.status==="Active"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t[15]||(t[15]=e.createElementVNode("small",{class:"text-muted"},"Active Duration:",-1)),e.createElementVNode("p",_e,e.toDisplayString(s.getDuration(n.date,n.registrationNumber)),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[t[16]||(t[16]=e.createElementVNode("small",{class:"text-muted"},"Inactive Duration:",-1)),e.createElementVNode("p",Se,e.toDisplayString(s.getDuration(n.date,n.registrationNumber)),1)],64))])):(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("small",ue,e.toDisplayString(n.status)+" Duration:",1),e.createElementVNode("button",{type:"button",class:"btn btn-outline-primary btn-sm mt-1",onClick:e.withModifiers(a=>s.setVesselDate(n.registrationNumber),["stop"])}," Set Date ",8,Be)]))])])]),e.createElementVNode("div",xe,[e.createElementVNode("i",{class:"bi bi-trash",onClick:e.withModifiers(a=>s.handleDeleteVessel(n),["stop"])},null,8,Te)]),e.createElementVNode("button",{class:"btn btn-primary",onClick:e.withModifiers(a=>s.handleToggleStatus(n),["stop"])},e.toDisplayString(n.status==="Active"?"Mark Inactive":"Mark Active"),9,Re)],8,ye)]))),128))]))],64)}const A=F(v,[["render",Ae]]),Nm="",Pe={name:"DashHead",props:{name:{type:String,required:!0},userProfile:{type:Object,required:!0,default:()=>({role:"viewer",vessel:null})}},emits:["add-user","logged-in"],methods:{addUser(){this.$emit("add-user")},loggedIn(){this.$emit("logged-in")}}},Me={class:"page-header d-flex justify-content-between align-items-center"},Ie={style:{"margin-left":"20px"}},Le={class:"d-flex"};function qe(o,t,r,l,i,s){return e.openBlock(),e.createElementBlock("div",Me,[e.createElementVNode("h4",Ie,e.toDisplayString(r.name),1),e.createElementVNode("div",Le,[this.userProfile.role=="owner"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-outline-primary me-2",onClick:t[0]||(t[0]=n=>s.addUser())},t[2]||(t[2]=[e.createElementVNode("i",{class:"bi bi-bell"},null,-1),e.createElementVNode("span",{class:"badge bg-danger"},"1",-1)]))):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"btn btn-outline-primary",onClick:t[1]||(t[1]=n=>s.loggedIn())},t[3]||(t[3]=[e.createElementVNode("i",{class:"bi bi-person-circle"},null,-1)]))])])}const P=F(Pe,[["render",qe]]),bm="",ze={name:"Reports",props:{reports:{type:Array,default:()=>[]},reportFiles:{type:Array,default:()=>[]},folders:{type:Array,default:()=>[]},isLoading:{type:Boolean,default:!1},isSubmitting:{type:Boolean,default:!1},pendingContext:{type:Object,default:null},missingReports:{type:Array,default:()=>[]},highlightRef:{type:String,default:null}},emits:["report-submit-requested","report-delete-requested","folder-create-requested","files-add-requested","file-remove-requested","folder-delete-requested","report-viewed"],data(){return{activeTab:"all",showNewFolderModal:!1,newFolderName:"",selectedFolder:null,expandedFolders:[],showReportModal:!1,showViewModal:!1,viewingReport:null,highlightedRef:null,bannerDismissed:!1,generatingPdf:null,drillChecklistQuestions:["Is the reaction of crew members satisfactory?","Is the equipment functioning properly?","Is the crew properly trained and ready?","Was debriefing conducted on completion of drill?","Is time log of various activities marked on checklist?"],reportForm:this.emptyForm()}},computed:{drillReports(){return this.reports.filter(o=>o.entityType==="drill")},incidentReports(){return this.reports.filter(o=>o.entityType==="incident")},manualReports(){return this.reports.filter(o=>{var t,r;return o.entityType==="manual"||!o.entityType&&!((t=o.entityRef)!=null&&t.startsWith("DRILL"))&&!((r=o.entityRef)!=null&&r.startsWith("INC"))})},filteredReports(){switch(this.activeTab){case"drill":return this.drillReports;case"incident":return this.incidentReports;case"manual":return this.manualReports;default:return this.reports}},zipName(){return(this.reportForm.entity_ref||this.reportForm.manual_ref||this.reportForm.title||"report").replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,50)}},watch:{pendingContext:{immediate:!0,handler(o){o&&(this.reportForm.entity_type=o.entity_type,this.reportForm.entity_id=o.entity_id,this.reportForm.entity_ref=o.entity_ref,this.reportForm.entity_label=o.title,this.reportForm.title=o.title||`Report — ${o.entity_ref}`,this.reportForm.report_type="qhse",this.reportForm.entity_creator=o.entity_creator,this.reportForm.entity_objectives=o.entity_objectives,this.reportForm.entity_subtype=o.entity_subtype,this.reportForm.entity_duration=o.entity_duration,this.reportForm.entity_participants=o.entity_participants,o.entity_type==="incident"&&o.entity_objectives&&(this.reportForm.findings=o.entity_objectives))}},highlightRef:{immediate:!0,handler(o){o&&(this.highlightedRef=o,this.$nextTick(()=>this.scrollToReport(o)))}},isSubmitting(o,t){t===!0&&o===!1&&(this.showReportModal=!1,this.resetForm())}},methods:{emptyForm(){return{report_type:"qhse",manual_category:"General",manual_ref:"",title:"",submittedBy:"",vessel:"",folderId:"",date:new Date().toISOString().split("T")[0],findings:"",correctiveActions:"",files:[],entity_type:"",entity_id:"",entity_ref:"",entity_label:"",entity_creator:"",entity_objectives:"",entity_subtype:"",entity_duration:"",entity_participants:null,selectedMissing:"",drillChecklist:[!0,!0,!0,!0,!0],inc_consequences:"",inc_factors:"",inc_immediate_action:"",inc_direct_cause:"",inc_root_cause:"",inc_remarks:""}},getFilesForReport(o){return this.reportFiles.filter(t=>t.report_id===o||t.reportId===o)},safeRef(o){return(o.entityRef||o.title||"report").replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,60)},reportTypeClass(o){const t=(o==null?void 0:o.entityType)||(o==null?void 0:o.entity_type);return t==="drill"?"drill":t==="incident"?"incident":"manual"},reportTypeLabel(o){const t=(o==null?void 0:o.entityType)||(o==null?void 0:o.entity_type);if(t==="drill")return"DRILL";if(t==="incident")return"INCIDENT";const r=(o==null?void 0:o.manualCategory)||(o==null?void 0:o.manual_category);return r?r.toUpperCase():"MANUAL"},fileIcon(o){return o?o.startsWith("image/")?"bi-file-earmark-image":o==="application/pdf"?"bi-file-earmark-pdf-fill":o.includes("word")?"bi-file-earmark-word":o.includes("sheet")||o.includes("excel")?"bi-file-earmark-excel":"bi-file-earmark":"bi-file-earmark"},ffiIconClass(o){const t=(o==null?void 0:o.type)||"";return t.startsWith("image/")?"ffi-icon--img":t==="application/pdf"?"ffi-icon--pdf":"ffi-icon--generic"},dismissBanner(){this.bannerDismissed=!0},openReportForm(o="qhse"){this.reportForm=this.emptyForm(),this.reportForm.report_type=o,o==="qhse"&&this.pendingContext&&(this.reportForm.entity_creator=this.pendingContext.entity_creator,this.reportForm.entity_objectives=this.pendingContext.entity_objectives,this.reportForm.entity_subtype=this.pendingContext.entity_subtype,this.reportForm.entity_duration=this.pendingContext.entity_duration,this.reportForm.entity_participants=this.pendingContext.entity_participants,this.reportForm.entity_type=this.pendingContext.entity_type,this.reportForm.entity_id=this.pendingContext.entity_id,this.reportForm.entity_ref=this.pendingContext.entity_ref,this.reportForm.entity_label=this.pendingContext.title,this.reportForm.title=this.pendingContext.title||`Report — ${this.pendingContext.entity_ref}`,this.pendingContext.entity_type==="incident"&&this.pendingContext.entity_objectives&&(this.reportForm.findings=this.pendingContext.entity_objectives)),this.showReportModal=!0},closeReportForm(){this.showReportModal=!1},clearEntityLink(){Object.assign(this.reportForm,{entity_type:"",entity_id:"",entity_ref:"",entity_label:"",entity_creator:"",entity_objectives:"",entity_subtype:"",entity_duration:"",entity_participants:null,selectedMissing:""})},applyMissingSelection(){if(!this.reportForm.selectedMissing)return;const o=JSON.parse(this.reportForm.selectedMissing);this.reportForm.entity_type=o.entity_type,this.reportForm.entity_id=o.entity_id,this.reportForm.entity_ref=o.entity_ref,this.reportForm.entity_label=o.label,this.reportForm.entity_creator=o.entity_creator||"",this.reportForm.entity_objectives=o.entity_objectives||"",this.reportForm.entity_subtype=o.entity_subtype||"",this.reportForm.entity_duration=o.entity_duration||"",this.reportForm.entity_participants=o.entity_participants||null,this.reportForm.title||(this.reportForm.title=`Report — ${o.entity_ref}`),o.entity_type==="incident"&&o.entity_objectives&&!this.reportForm.findings&&(this.reportForm.findings=o.entity_objectives)},requestSubmitReport(){!this.reportForm.title||!this.reportForm.submittedBy||!this.reportForm.findings||this.$emit("report-submit-requested",{entity_type:this.reportForm.report_type==="manual"?"manual":this.reportForm.entity_type,entity_id:this.reportForm.entity_id||null,entity_ref:this.reportForm.report_type==="manual"?this.reportForm.manual_ref||null:this.reportForm.entity_ref,title:this.reportForm.title,submittedBy:this.reportForm.submittedBy,vessel:this.reportForm.vessel||null,date:this.reportForm.date,findings:this.reportForm.findings,correctiveActions:this.reportForm.correctiveActions||null,folderId:null,folderName:null,manual_category:this.reportForm.report_type==="manual"?this.reportForm.manual_category:null,files:this.reportForm.files,entity_subtype:this.reportForm.entity_subtype||null,entity_creator:this.reportForm.entity_creator||null,entity_objectives:this.reportForm.entity_objectives||null,entity_duration:this.reportForm.entity_duration||null,entity_participants:this.reportForm.entity_participants||null,drill_checklist:[...this.reportForm.drillChecklist],inc_consequences:this.reportForm.inc_consequences||null,inc_factors:this.reportForm.inc_factors||null,inc_immediate_action:this.reportForm.inc_immediate_action||null,inc_direct_cause:this.reportForm.inc_direct_cause||null,inc_root_cause:this.reportForm.inc_root_cause||null,inc_remarks:this.reportForm.inc_remarks||null})},resetForm(){this.reportForm=this.emptyForm()},highlightReport(o){this.highlightedRef=o,this.$nextTick(()=>this.scrollToReport(o)),setTimeout(()=>{this.highlightedRef=null},3e3)},viewReport(o){this.viewingReport=o,this.showViewModal=!0,this.$emit("report-viewed",o)},closeViewer(){this.showViewModal=!1,this.viewingReport=null},requestDeleteReport(o){this.closeViewer(),this.$emit("report-delete-requested",o)},scrollToReport(o){this.$nextTick(()=>{var r;const t=this.$refs["report-"+o];t&&((r=Array.isArray(t)?t[0]:t)==null||r.scrollIntoView({behavior:"smooth",block:"center"}))})},jumpToFolder(o){this.activeTab="folders";const t="auto-"+o.id;this.expandedFolders.includes(t)||this.expandedFolders.push(t),this.$nextTick(()=>{var i;const r=o.entityRef||o.id,l=this.$refs["folder-"+r];l&&((i=Array.isArray(l)?l[0]:l)==null||i.scrollIntoView({behavior:"smooth",block:"center"}))})},async downloadReport(o){this.generatingPdf=o.id;try{await this._loadLibraries();const t=this.getFilesForReport(o.id),r=t.filter(i=>{var s;return(s=i.type)==null?void 0:s.startsWith("image/")}),l=await this._buildReportPdf(o,r);await this._buildAndDownloadZip(o,l,t)}catch(t){console.error("ZIP generation failed:",t),alert("Failed to generate download: "+t.message)}finally{this.generatingPdf=null}},async downloadReportPdfOnly(o){this.generatingPdf=o.id+"-pdf";try{await this._loadLibraries();const t=this.getFilesForReport(o.id).filter(i=>{var s;return(s=i.type)==null?void 0:s.startsWith("image/")}),r=await this._buildReportPdf(o,t),l=new Blob([r],{type:"application/pdf"});this._triggerDownload(l,`${this.safeRef(o)}_report.pdf`)}catch(t){alert("Failed to generate PDF: "+t.message)}finally{this.generatingPdf=null}},async _loadLibraries(){window.jspdf||await this._loadScript("https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"),window.JSZip||await this._loadScript("https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js")},_loadScript(o){return new Promise((t,r)=>{if(document.querySelector(`script[src="${o}"]`)){t();return}const l=document.createElement("script");l.src=o,l.onload=t,l.onerror=r,document.head.appendChild(l)})},async _buildReportPdf(o,t=[]){const r=o.entityType||o.entity_type;return r==="drill"?this._buildDrillPdf(o,t):r==="incident"?this._buildIncidentPdf(o,t):this._buildManualPdf(o,t)},async _buildDrillPdf(o,t=[]){var x,u;const{jsPDF:r}=window.jspdf,l=new r({orientation:"portrait",unit:"mm",format:"a4"}),i=210,s=15,n=i-s*2;let a=0;const c=(f=10)=>{a+f>275&&(l.addPage(),a=20)},y=f=>{c(12),l.setFillColor(26,54,107),l.rect(s,a,n,7,"F"),l.setTextColor(255,255,255),l.setFontSize(8.5),l.setFont("helvetica","bold"),l.text(f.toUpperCase(),s+3,a+5),a+=10,l.setTextColor(30,30,30)},w=(f,E,S=68)=>{c(7),l.setFontSize(9),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text(f,s+2,a),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(":",s+S-6,a);const B=l.splitTextToSize(String(E||"—"),n-S-4);l.text(B,s+S,a),a+=Math.max(B.length*5,5)+2};l.setFillColor(26,54,107),l.rect(0,0,i,24,"F"),l.setDrawColor(255,200,50),l.setLineWidth(1.2),l.line(s,23.4,i-s,23.4),l.setTextColor(255,255,255),l.setFontSize(14),l.setFont("helvetica","bold"),l.text("EMERGENCY DRILL REPORT",i/2,10,{align:"center"}),l.setFontSize(8),l.setFont("helvetica","normal"),l.setTextColor(200,215,240),l.text("Quality, Health, Safety & Environment Management System",i/2,17,{align:"center"}),a=30,o.entityRef&&(l.setFillColor(240,245,255),l.roundedRect(i-s-44,26,44,8,2,2,"F"),l.setTextColor(26,54,107),l.setFontSize(8),l.setFont("helvetica","bold"),l.text(o.entityRef,i-s-2,31,{align:"right"}),l.setTextColor(30,30,30)),l.setDrawColor(180,190,210),l.setLineWidth(.4),l.rect(s,a,n,28,"S"),l.line(s+n/2,a,s+n/2,a+28),l.line(s,a+14,s+n/2,a+14),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("VESSEL:",s+3,a+6),l.setFont("helvetica","bold"),l.setTextColor(20,20,20),l.setFontSize(10),l.text(String(o.vessel||"—").toUpperCase(),s+22,a+6),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("DATE / PLACE:",s+3,a+20),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(`${o.date||"—"} / ${o.vessel||"—"}`,s+33,a+20);const N=s+n/2+3;l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("KIND OF DRILL:",N,a+6),l.setFontSize(11),l.setFont("helvetica","bold"),l.setTextColor(26,54,107),l.text(String(o.entity_subtype||"—").toUpperCase(),N,a+16),l.setFontSize(7.5),l.setFont("helvetica","italic"),l.setTextColor(120,120,120),l.text("RELEVANT IMAGES/NOTES ARE ATTACHED",N,a+23),a+=32,y("Drill Details"),w("Drill Master / Conducted By",o.entity_creator),w("Duration",o.entity_duration),w("Objectives",o.entity_objectives),w("Submitted By",o.submittedBy),w("Submitted At",this.formatDate(o.submittedAt)),a+=2;const D=o.entity_participants||0;y(`Crew Participation — ${D} member${D!==1?"s":""} participated`);const _=(()=>{const f=(o.findings||"").trim();if(/^CREW:/i.test(f))return f.replace(/^CREW:\s*/i,"").split(/\n\n/)[0].split(/[\n,]+/).map(B=>B.trim()).filter(Boolean);const E=[];return o.entity_creator&&E.push(`${o.entity_creator} (Drill Master)`),o.submittedBy&&o.submittedBy!==o.entity_creator&&E.push(`${o.submittedBy} (Reporter)`),E})();c(14);const C=s,p=12,h=s+p,b=n-p;l.setFillColor(235,240,250),l.rect(C,a,n,7,"F"),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(26,54,107),l.text("NO.",C+2,a+5),l.text("NAME / RANK",h+2,a+5),a+=8,_.length>0?_.forEach((f,E)=>{c(7),E%2===0&&(l.setFillColor(249,250,252),l.rect(C,a-1,n,7,"F")),l.setFontSize(8.5),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.text(String(E+1),C+2,a+4),l.text(l.splitTextToSize(f,b-4)[0],h+2,a+4),a+=7}):(c(8),l.setFontSize(8.5),l.setFont("helvetica","italic"),l.setTextColor(150,150,150),l.text(`${D} crew members participated — attach signed crew list with participants' signatures`,h+2,a+4),a+=8),a+=4,y("Comments");const k=["Is the reaction of crew members satisfactory?","Is the equipment functioning properly?","Is the crew properly trained and ready?","Was debriefing conducted on completion of drill?","Is time log of various activities marked on checklist?"],d=(()=>{const f=o.drill_checklist||o.drillChecklist;if(Array.isArray(f))return f;try{return JSON.parse(f)}catch{return[!0,!0,!0,!0,!0]}})();k.forEach((f,E)=>{c(9);const S=d[E]!==!1;l.setFontSize(8.5),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.text(`${E+1}. ${f}`,s+3,a+5),S?(l.setFillColor(212,237,218),l.roundedRect(i-s-18,a+1,18,6,2,2,"F"),l.setTextColor(21,87,36),l.setFont("helvetica","bold"),l.setFontSize(7.5),l.text("YES",i-s-9,a+5.5,{align:"center"})):(l.setFillColor(248,215,218),l.roundedRect(i-s-18,a+1,18,6,2,2,"F"),l.setTextColor(114,28,36),l.setFont("helvetica","bold"),l.setFontSize(7.5),l.text("NO",i-s-9,a+5.5,{align:"center"})),a+=9}),a+=3;const m=(()=>{const f=(o.findings||"").trim();return/^CREW:/i.test(f)?f.split(/\n\n+/).slice(1).join(`
1
+ (function(V,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(V=typeof globalThis<"u"?globalThis:V||self,e(V.OceanHelm={},V.Vue))})(this,function(V,e){"use strict";const ym="",S=(o,t)=>{const r=o.__vccOpts||o;for(const[l,n]of t)r[l]=n;return r},O={name:"ConfigurableSidebar",props:{brandName:{type:String,default:"OceanHelm"},logoIcon:{type:String,default:"bi bi-water"},showLogo:{type:Boolean,default:!0},menuItems:{type:Array,required:!0,default:()=>[]},userProfile:{type:Object,default:()=>({})},responsive:{type:Boolean,default:!0},customClasses:{type:String,default:""},permissionChecker:{type:Function,default:null}},computed:{sidebarClasses(){return this.customClasses},filteredMenuItems(){return this.menuItems.filter(o=>this.hasPermission(o)?o.type==="dropdown"&&o.children?o.children.some(t=>this.hasPermission(t)):!0:!1)}},mounted(){this.responsive&&this.initializeResponsiveBehavior()},methods:{toggleDropdown(o){this.filteredMenuItems.forEach(t=>{t!==o&&t.type==="dropdown"&&(t.open=!1)}),o.open=!o.open},getFilteredChildren(o){return o.children?o.children.filter(t=>this.hasPermission(t)):[]},hasPermission(o){var l,n;if(this.permissionChecker)return this.permissionChecker(o,this.userProfile);const t=((l=this.userProfile)==null?void 0:l.role)||"",r=((n=this.userProfile)==null?void 0:n.categories)||[];return!o.roles||o.roles.length===0?!0:!(!o.roles.includes(t)||o.categories&&o.categories.length>0&&!["owner","super-staff"].includes(t)&&!o.categories.some(a=>r.includes(a)))},handleNavigation(o){var t;this.$emit("navigate",o),o.href&&!o.preventDefault&&(o.external?window.open(o.href,"_blank"):(t=this.$router)==null||t.push(o.href))},handleAction(o){this.$emit("action",o)},handleItemClick(o){this.$emit("item-click",o)},initializeResponsiveBehavior(){const o=document.getElementById("sidebarToggle"),t=document.getElementById("sidebar"),r=document.getElementById("content");!o||!t||!r||(window.innerWidth>=768&&(t.classList.toggle("active"),r.classList.toggle("active")),o.addEventListener("click",()=>{t.classList.toggle("active"),r.classList.toggle("active")}),document.addEventListener("click",l=>{const n=t.contains(l.target),i=o.contains(l.target);!n&&!i&&window.innerWidth<768&&t.classList.contains("active")&&(t.classList.remove("active"),r.classList.remove("active"))}))}},emits:["navigate","action","item-click"]},U={key:0,class:"logo d-flex align-items-center left"},j={style:{"margin-left":"45px"}},G={class:"list-unstyled components mt-4"},H=["onClick"],W=["href","onClick"],Q=["onClick"],J=["onClick"],Y={class:"sidebar-dropdown"},Z=["onClick"],K={key:3,class:"dropdown-divider"},$={key:4};function X(o,t,r,l,n,i){return e.openBlock(),e.createElementBlock("nav",{id:"sidebar",class:e.normalizeClass(i.sidebarClasses)},[r.showLogo?(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("span",j,e.toDisplayString(r.brandName),1)])):e.createCommentVNode("",!0),e.createElementVNode("ul",G,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.filteredMenuItems,(s,a)=>(e.openBlock(),e.createElementBlock("li",{key:a,class:e.normalizeClass({active:s.active,dropdown:s.type==="dropdown"}),onClick:c=>i.handleItemClick(s)},[s.type==="link"?(e.openBlock(),e.createElementBlock("a",{key:0,href:s.href||"#",onClick:e.withModifiers(c=>i.handleNavigation(s),["prevent"])},[s.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(s.icon)},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(s.label),1)],8,W)):s.type==="button"?(e.openBlock(),e.createElementBlock("a",{key:1,onClick:e.withModifiers(c=>i.handleAction(s),["prevent"]),style:{cursor:"pointer"}},[s.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(s.icon)},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(s.label),1)],8,Q)):s.type==="dropdown"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("a",{class:"dropdown-toggle",onClick:e.withModifiers(c=>i.toggleDropdown(s),["prevent"]),style:{cursor:"pointer"}},[s.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(s.icon)},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(s.label)+" ",1),e.createElementVNode("i",{class:e.normalizeClass(["",{open:s.open}])},null,2)],8,J),e.withDirectives(e.createElementVNode("ul",Y,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.getFilteredChildren(s),(c,y)=>(e.openBlock(),e.createElementBlock("li",{key:y},[e.createElementVNode("a",{class:"dropdown-item",onClick:e.withModifiers(w=>i.handleAction(c),["prevent"])},e.toDisplayString(c.label),9,Z)]))),128))],512),[[e.vShow,s.open]])],64)):s.type==="separator"?(e.openBlock(),e.createElementBlock("div",K)):s.type==="text"?(e.openBlock(),e.createElementBlock("a",$,e.toDisplayString(s.label),1)):e.createCommentVNode("",!0)],10,H))),128))]),e.renderSlot(o.$slots,"footer")],2)}const R=S(O,[["render",X]]),Em="",v={name:"VesselList",props:{vessels:{type:Array,required:!0,default:()=>[]},userProfile:{type:Object,required:!0,default:()=>({role:"viewer",vessel:null})},loading:{type:Boolean,default:!1},currentRoute:{type:String,default:"dashboard"},config:{type:Object,default:()=>({enableAdd:!0,enableEdit:!0,enableDelete:!0,enableStatusToggle:!0,showCertifications:!0})}},data(){return{activeFilter:"All"}},emits:["vessel-add","vessel-click","vessel-edit","vessel-delete","vessel-toggle-status","vessel-navigate","access-denied","date-change"],computed:{activeVesselsCount(){return this.vessels.filter(o=>o.status==="Active").length},inactiveVesselsCount(){return this.vessels.filter(o=>o.status==="Inactive").length},filteredVessels(){return this.activeFilter==="All"?this.vessels:this.vessels.filter(o=>o.status===this.activeFilter)},canAddVessel(){return this.config.enableAdd&&(this.userProfile.role==="owner"||this.userProfile.role==="staff")}},methods:{filterVessels(o){this.activeFilter=o},clearFilter(){this.activeFilter="All"},handleAddVessel(){if(!this.canAddVessel){this.handleAccessDenied("add vessel");return}this.$emit("vessel-add")},handleVesselClick(o){const t={vessel:o,route:this.currentRoute,id:o.registrationNumber,name:o.name};this.grantAccess(o)?this.currentRoute==="dashboard"?this.$emit("vessel-click",o):this.$emit("vessel-navigate",t):this.handleAccessDenied("this protected route")},handleDeleteVessel(o){if(!this.grantAccess(o)){this.handleAccessDenied("delete vessel");return}this.config.enableDelete&&this.$emit("vessel-delete",o)},handleToggleStatus(o){if(!this.grantAccess(o)){this.handleAccessDenied("change vessel status");return}this.config.enableStatusToggle&&this.$emit("vessel-toggle-status",o)},handleEditVessel(o){if(!this.grantAccess(o)){this.handleAccessDenied("edit vessel");return}this.config.enableEdit&&this.$emit("vessel-edit",o)},handleAccessDenied(o){this.$emit("access-denied",{action:o,userProfile:this.userProfile})},statusClass(o){return`status-${(o==null?void 0:o.toLowerCase())||""}`},getDuration(o,t){const r=new Date,l=new Date(o),n=r-l;if(n<0)return"Invalid (future date)";const i=Math.floor(n/(1e3*60*60)),s=Math.floor(i/24),a=i%24;let c="";return s>0&&(c+=`${s} day${s>1?"s":""}`),a>0&&(c+=(c?" ":"")+`${a} hr${a>1?"s":""}`),c||"0 hr"},setVesselDate(o){this.$emit("date-change",o)},grantAccess(o){const{role:t,vessel:r}=this.userProfile;return t==="owner"||t==="staff"||t==="captain"&&r===o.name},getDaysToExpiry(o){if(!o)return null;const t=new Date,l=new Date(o)-t;return Math.ceil(l/(1e3*60*60*24))},getExpiryClass(o){const t=this.getDaysToExpiry(o);return t===null?"":t<30?"cert-critical":t<90?"cert-warning":""}}},ee={class:"row mb-3"},te={class:"col-md-4"},oe={class:"card-body d-flex align-items-center"},se={class:"mt-2 mb-0"},ne={class:"col-md-4"},ie={class:"card-body d-flex align-items-center"},le={class:"mt-2 mb-0"},re={key:0,class:"col-md-4"},ae={class:"d-flex justify-content-between align-items-center mb-4"},de={key:0,class:"alert alert-info mb-3",role:"alert"},ce={key:1,class:"text-center py-4"},me={key:2,class:"alert alert-primary",role:"alert"},pe={key:3,class:"alert alert-warning",role:"alert"},fe={class:"alert-heading"},he={class:"mb-0"},ge={key:4,class:"row"},ye=["onClick"],Ee={class:"card-body d-flex align-items-center"},Ne={class:"flex-grow-1"},be={class:"d-flex justify-content-between align-items-center mb-2"},Ve={class:"card-title mb-0"},ke={class:"row"},we={class:"col-6"},Ce={class:"mb-0"},De={key:0,class:"col-6"},_e={class:"mb-0"},ue={class:"mb-0"},Se={key:1,class:"col-6"},Fe={class:"text-muted"},Be=["onClick"],xe={class:"action-icon v-left delete"},Te=["onClick"],Re=["onClick"];function Ae(o,t,r,l,n,i){return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ee,[e.createElementVNode("div",te,[e.createElementVNode("div",{class:e.normalizeClass(["card border-0 shadow-sm",{"border-primary border-2":n.activeFilter==="Active"}]),onClick:t[0]||(t[0]=s=>i.filterVessels("Active")),style:{cursor:"pointer"}},[e.createElementVNode("div",oe,[t[5]||(t[5]=e.createElementVNode("div",{class:"rounded-circle bg-primary bg-opacity-10 p-3 me-3"},[e.createElementVNode("i",{class:"bi bi-check-circle-fill text-primary fs-4"})],-1)),e.createElementVNode("div",null,[t[4]||(t[4]=e.createElementVNode("h6",{class:"mb-0"},"Active Vessels",-1)),e.createElementVNode("h3",se,e.toDisplayString(i.activeVesselsCount),1)])])],2)]),e.createElementVNode("div",ne,[e.createElementVNode("div",{class:e.normalizeClass(["card border-0 shadow-sm",{"border-secondary border-2":n.activeFilter==="Inactive"}]),onClick:t[1]||(t[1]=s=>i.filterVessels("Inactive")),style:{cursor:"pointer"}},[e.createElementVNode("div",ie,[t[7]||(t[7]=e.createElementVNode("div",{class:"rounded-circle bg-secondary bg-opacity-10 p-3 me-3"},[e.createElementVNode("i",{class:"bi bi-pause-circle-fill text-secondary fs-4"})],-1)),e.createElementVNode("div",null,[t[6]||(t[6]=e.createElementVNode("h6",{class:"mb-0"},"Inactive",-1)),e.createElementVNode("h3",le,e.toDisplayString(i.inactiveVesselsCount),1)])])],2)]),i.canAddVessel?(e.openBlock(),e.createElementBlock("div",re,[e.createElementVNode("div",{class:"card border-0 shadow-sm",onClick:t[2]||(t[2]=(...s)=>i.handleAddVessel&&i.handleAddVessel(...s)),style:{cursor:"pointer"}},t[8]||(t[8]=[e.createElementVNode("div",{class:"card-body d-flex align-items-center"},[e.createElementVNode("div",{class:"rounded-circle bg-success bg-opacity-10 p-3 me-3"},[e.createElementVNode("i",{class:"bi bi-patch-plus-fill text-success fs-4"})]),e.createElementVNode("div",null,[e.createElementVNode("h6",{class:"mb-0"},"Add New Vessel")])],-1)]))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",ae,[t[10]||(t[10]=e.createElementVNode("h4",{class:"mb-0"},[e.createElementVNode("i",{class:"bi bi-ship me-2"}),e.createTextVNode("Registered Vessels")],-1)),n.activeFilter!=="All"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-sm btn-outline-secondary",onClick:t[3]||(t[3]=(...s)=>i.clearFilter&&i.clearFilter(...s))},t[9]||(t[9]=[e.createElementVNode("i",{class:"bi bi-x-circle me-1"},null,-1),e.createTextVNode("Clear Filter ",-1)]))):e.createCommentVNode("",!0)]),n.activeFilter!=="All"?(e.openBlock(),e.createElementBlock("div",de,[t[11]||(t[11]=e.createTextVNode(" Showing ",-1)),e.createElementVNode("strong",null,e.toDisplayString(n.activeFilter),1),e.createTextVNode(" vessels ("+e.toDisplayString(i.filteredVessels.length)+") ",1)])):e.createCommentVNode("",!0),r.loading?(e.openBlock(),e.createElementBlock("div",ce,t[12]||(t[12]=[e.createElementVNode("div",{class:"spinner-border text-primary",role:"status"},[e.createElementVNode("span",{class:"visually-hidden"},"Loading...")],-1),e.createElementVNode("p",{class:"mt-2"},"Loading vessels...",-1)]))):!i.filteredVessels.length&&n.activeFilter==="All"?(e.openBlock(),e.createElementBlock("div",me,t[13]||(t[13]=[e.createElementVNode("h4",{class:"alert-heading"},"Empty Fleet!",-1),e.createElementVNode("p",null,"You have an empty fleet, you have not added any vessel yet.",-1),e.createElementVNode("hr",null,null,-1),e.createElementVNode("p",{class:"mb-0"},"Click on the add vessel button above, to start adding vessels to your fleet",-1)]))):!i.filteredVessels.length&&n.activeFilter!=="All"?(e.openBlock(),e.createElementBlock("div",pe,[e.createElementVNode("h4",fe,"No "+e.toDisplayString(n.activeFilter)+" Vessels",1),e.createElementVNode("p",he,"There are no "+e.toDisplayString(n.activeFilter.toLowerCase())+" vessels in your fleet.",1)])):(e.openBlock(),e.createElementBlock("div",ge,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.filteredVessels,s=>(e.openBlock(),e.createElementBlock("div",{class:"col-lg-6",key:s.registrationNumber||s.id},[e.createElementVNode("div",{class:"vessel-card",onClick:a=>i.handleVesselClick(s)},[e.createElementVNode("div",Ee,[t[17]||(t[17]=e.createElementVNode("div",{class:"vessel-icon v-left"},[e.createElementVNode("i",{class:"fas fa-ship"})],-1)),e.createElementVNode("div",Ne,[e.createElementVNode("div",be,[e.createElementVNode("h5",Ve,e.toDisplayString(s.name),1),e.createElementVNode("span",{class:e.normalizeClass(["vessel-status",i.statusClass(s.status)])},e.toDisplayString(s.status),3)]),e.createElementVNode("div",ke,[e.createElementVNode("div",we,[t[14]||(t[14]=e.createElementVNode("small",{class:"text-muted"},"Registration #:",-1)),e.createElementVNode("p",Ce,e.toDisplayString(s.registrationNumber),1)]),s.date?(e.openBlock(),e.createElementBlock("div",De,[s.status==="Active"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t[15]||(t[15]=e.createElementVNode("small",{class:"text-muted"},"Active Duration:",-1)),e.createElementVNode("p",_e,e.toDisplayString(i.getDuration(s.date,s.registrationNumber)),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[t[16]||(t[16]=e.createElementVNode("small",{class:"text-muted"},"Inactive Duration:",-1)),e.createElementVNode("p",ue,e.toDisplayString(i.getDuration(s.date,s.registrationNumber)),1)],64))])):(e.openBlock(),e.createElementBlock("div",Se,[e.createElementVNode("small",Fe,e.toDisplayString(s.status)+" Duration:",1),e.createElementVNode("button",{type:"button",class:"btn btn-outline-primary btn-sm mt-1",onClick:e.withModifiers(a=>i.setVesselDate(s.registrationNumber),["stop"])}," Set Date ",8,Be)]))])])]),e.createElementVNode("div",xe,[e.createElementVNode("i",{class:"bi bi-trash",onClick:e.withModifiers(a=>i.handleDeleteVessel(s),["stop"])},null,8,Te)]),e.createElementVNode("button",{class:"btn btn-primary",onClick:e.withModifiers(a=>i.handleToggleStatus(s),["stop"])},e.toDisplayString(s.status==="Active"?"Mark Inactive":"Mark Active"),9,Re)],8,ye)]))),128))]))],64)}const A=S(v,[["render",Ae]]),Nm="",Pe={name:"DashHead",props:{name:{type:String,required:!0},userProfile:{type:Object,required:!0,default:()=>({role:"viewer",vessel:null})}},emits:["add-user","logged-in"],methods:{addUser(){this.$emit("add-user")},loggedIn(){this.$emit("logged-in")}}},Me={class:"page-header d-flex justify-content-between align-items-center"},Ie={style:{"margin-left":"20px"}},Le={class:"d-flex"};function qe(o,t,r,l,n,i){return e.openBlock(),e.createElementBlock("div",Me,[e.createElementVNode("h4",Ie,e.toDisplayString(r.name),1),e.createElementVNode("div",Le,[this.userProfile.role=="owner"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-outline-primary me-2",onClick:t[0]||(t[0]=s=>i.addUser())},t[2]||(t[2]=[e.createElementVNode("i",{class:"bi bi-bell"},null,-1),e.createElementVNode("span",{class:"badge bg-danger"},"1",-1)]))):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"btn btn-outline-primary",onClick:t[1]||(t[1]=s=>i.loggedIn())},t[3]||(t[3]=[e.createElementVNode("i",{class:"bi bi-person-circle"},null,-1)]))])])}const P=S(Pe,[["render",qe]]),bm="",ze={name:"Reports",props:{reports:{type:Array,default:()=>[]},reportFiles:{type:Array,default:()=>[]},folders:{type:Array,default:()=>[]},isLoading:{type:Boolean,default:!1},isSubmitting:{type:Boolean,default:!1},pendingContext:{type:Object,default:null},missingReports:{type:Array,default:()=>[]},highlightRef:{type:String,default:null}},emits:["report-submit-requested","report-delete-requested","folder-create-requested","files-add-requested","file-remove-requested","folder-delete-requested","report-viewed"],data(){return{activeTab:"all",showNewFolderModal:!1,newFolderName:"",selectedFolder:null,expandedFolders:[],showReportModal:!1,showViewModal:!1,viewingReport:null,highlightedRef:null,bannerDismissed:!1,generatingPdf:null,drillChecklistQuestions:["Is the reaction of crew members satisfactory?","Is the equipment functioning properly?","Is the crew properly trained and ready?","Was debriefing conducted on completion of drill?","Is time log of various activities marked on checklist?"],reportForm:this.emptyForm()}},computed:{drillReports(){return this.reports.filter(o=>o.entityType==="drill")},incidentReports(){return this.reports.filter(o=>o.entityType==="incident")},manualReports(){return this.reports.filter(o=>{var t,r;return o.entityType==="manual"||!o.entityType&&!((t=o.entityRef)!=null&&t.startsWith("DRILL"))&&!((r=o.entityRef)!=null&&r.startsWith("INC"))})},filteredReports(){switch(this.activeTab){case"drill":return this.drillReports;case"incident":return this.incidentReports;case"manual":return this.manualReports;default:return this.reports}},zipName(){return(this.reportForm.entity_ref||this.reportForm.manual_ref||this.reportForm.title||"report").replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,50)}},watch:{pendingContext:{immediate:!0,handler(o){o&&(this.reportForm.entity_type=o.entity_type,this.reportForm.entity_id=o.entity_id,this.reportForm.entity_ref=o.entity_ref,this.reportForm.entity_label=o.title,this.reportForm.title=o.title||`Report — ${o.entity_ref}`,this.reportForm.report_type="qhse",this.reportForm.entity_creator=o.entity_creator,this.reportForm.entity_objectives=o.entity_objectives,this.reportForm.entity_subtype=o.entity_subtype,this.reportForm.entity_duration=o.entity_duration,this.reportForm.entity_participants=o.entity_participants,o.entity_type==="incident"&&o.entity_objectives&&(this.reportForm.findings=o.entity_objectives))}},highlightRef:{immediate:!0,handler(o){o&&(this.highlightedRef=o,this.$nextTick(()=>this.scrollToReport(o)))}},isSubmitting(o,t){t===!0&&o===!1&&(this.showReportModal=!1,this.resetForm())}},methods:{emptyForm(){return{report_type:"qhse",manual_category:"General",manual_ref:"",title:"",submittedBy:"",vessel:"",folderId:"",date:new Date().toISOString().split("T")[0],findings:"",correctiveActions:"",files:[],entity_type:"",entity_id:"",entity_ref:"",entity_label:"",entity_creator:"",entity_objectives:"",entity_subtype:"",entity_duration:"",entity_participants:null,selectedMissing:"",drillChecklist:[!0,!0,!0,!0,!0],inc_consequences:"",inc_factors:"",inc_immediate_action:"",inc_direct_cause:"",inc_root_cause:"",inc_remarks:""}},getFilesForReport(o){return this.reportFiles.filter(t=>t.report_id===o||t.reportId===o)},safeRef(o){return(o.entityRef||o.title||"report").replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,60)},reportTypeClass(o){const t=(o==null?void 0:o.entityType)||(o==null?void 0:o.entity_type);return t==="drill"?"drill":t==="incident"?"incident":"manual"},reportTypeLabel(o){const t=(o==null?void 0:o.entityType)||(o==null?void 0:o.entity_type);if(t==="drill")return"DRILL";if(t==="incident")return"INCIDENT";const r=(o==null?void 0:o.manualCategory)||(o==null?void 0:o.manual_category);return r?r.toUpperCase():"MANUAL"},fileIcon(o){return o?o.startsWith("image/")?"bi-file-earmark-image":o==="application/pdf"?"bi-file-earmark-pdf-fill":o.includes("word")?"bi-file-earmark-word":o.includes("sheet")||o.includes("excel")?"bi-file-earmark-excel":"bi-file-earmark":"bi-file-earmark"},ffiIconClass(o){const t=(o==null?void 0:o.type)||"";return t.startsWith("image/")?"ffi-icon--img":t==="application/pdf"?"ffi-icon--pdf":"ffi-icon--generic"},dismissBanner(){this.bannerDismissed=!0},openReportForm(o="qhse"){this.reportForm=this.emptyForm(),this.reportForm.report_type=o,o==="qhse"&&this.pendingContext&&(this.reportForm.entity_creator=this.pendingContext.entity_creator,this.reportForm.entity_objectives=this.pendingContext.entity_objectives,this.reportForm.entity_subtype=this.pendingContext.entity_subtype,this.reportForm.entity_duration=this.pendingContext.entity_duration,this.reportForm.entity_participants=this.pendingContext.entity_participants,this.reportForm.entity_type=this.pendingContext.entity_type,this.reportForm.entity_id=this.pendingContext.entity_id,this.reportForm.entity_ref=this.pendingContext.entity_ref,this.reportForm.entity_label=this.pendingContext.title,this.reportForm.title=this.pendingContext.title||`Report — ${this.pendingContext.entity_ref}`,this.pendingContext.entity_type==="incident"&&this.pendingContext.entity_objectives&&(this.reportForm.findings=this.pendingContext.entity_objectives)),this.showReportModal=!0},closeReportForm(){this.showReportModal=!1},clearEntityLink(){Object.assign(this.reportForm,{entity_type:"",entity_id:"",entity_ref:"",entity_label:"",entity_creator:"",entity_objectives:"",entity_subtype:"",entity_duration:"",entity_participants:null,selectedMissing:""})},applyMissingSelection(){if(!this.reportForm.selectedMissing)return;const o=JSON.parse(this.reportForm.selectedMissing);this.reportForm.entity_type=o.entity_type,this.reportForm.entity_id=o.entity_id,this.reportForm.entity_ref=o.entity_ref,this.reportForm.entity_label=o.label,this.reportForm.entity_creator=o.entity_creator||"",this.reportForm.entity_objectives=o.entity_objectives||"",this.reportForm.entity_subtype=o.entity_subtype||"",this.reportForm.entity_duration=o.entity_duration||"",this.reportForm.entity_participants=o.entity_participants||null,this.reportForm.title||(this.reportForm.title=`Report — ${o.entity_ref}`),o.entity_type==="incident"&&o.entity_objectives&&!this.reportForm.findings&&(this.reportForm.findings=o.entity_objectives)},requestSubmitReport(){!this.reportForm.title||!this.reportForm.submittedBy||!this.reportForm.findings||this.$emit("report-submit-requested",{entity_type:this.reportForm.report_type==="manual"?"manual":this.reportForm.entity_type,entity_id:this.reportForm.entity_id||null,entity_ref:this.reportForm.report_type==="manual"?this.reportForm.manual_ref||null:this.reportForm.entity_ref,title:this.reportForm.title,submittedBy:this.reportForm.submittedBy,vessel:this.reportForm.vessel||null,date:this.reportForm.date,findings:this.reportForm.findings,correctiveActions:this.reportForm.correctiveActions||null,folderId:null,folderName:null,manual_category:this.reportForm.report_type==="manual"?this.reportForm.manual_category:null,files:this.reportForm.files,entity_subtype:this.reportForm.entity_subtype||null,entity_creator:this.reportForm.entity_creator||null,entity_objectives:this.reportForm.entity_objectives||null,entity_duration:this.reportForm.entity_duration||null,entity_participants:this.reportForm.entity_participants||null,drill_checklist:[...this.reportForm.drillChecklist],inc_consequences:this.reportForm.inc_consequences||null,inc_factors:this.reportForm.inc_factors||null,inc_immediate_action:this.reportForm.inc_immediate_action||null,inc_direct_cause:this.reportForm.inc_direct_cause||null,inc_root_cause:this.reportForm.inc_root_cause||null,inc_remarks:this.reportForm.inc_remarks||null})},resetForm(){this.reportForm=this.emptyForm()},highlightReport(o){this.highlightedRef=o,this.$nextTick(()=>this.scrollToReport(o)),setTimeout(()=>{this.highlightedRef=null},3e3)},viewReport(o){this.viewingReport=o,this.showViewModal=!0,this.$emit("report-viewed",o)},closeViewer(){this.showViewModal=!1,this.viewingReport=null},requestDeleteReport(o){this.closeViewer(),this.$emit("report-delete-requested",o)},scrollToReport(o){this.$nextTick(()=>{var r;const t=this.$refs["report-"+o];t&&((r=Array.isArray(t)?t[0]:t)==null||r.scrollIntoView({behavior:"smooth",block:"center"}))})},jumpToFolder(o){this.activeTab="folders";const t="auto-"+o.id;this.expandedFolders.includes(t)||this.expandedFolders.push(t),this.$nextTick(()=>{var n;const r=o.entityRef||o.id,l=this.$refs["folder-"+r];l&&((n=Array.isArray(l)?l[0]:l)==null||n.scrollIntoView({behavior:"smooth",block:"center"}))})},async downloadReport(o){this.generatingPdf=o.id;try{await this._loadLibraries();const t=this.getFilesForReport(o.id),r=t.filter(n=>{var i;return(i=n.type)==null?void 0:i.startsWith("image/")}),l=await this._buildReportPdf(o,r);await this._buildAndDownloadZip(o,l,t)}catch(t){console.error("ZIP generation failed:",t),alert("Failed to generate download: "+t.message)}finally{this.generatingPdf=null}},async downloadReportPdfOnly(o){this.generatingPdf=o.id+"-pdf";try{await this._loadLibraries();const t=this.getFilesForReport(o.id).filter(n=>{var i;return(i=n.type)==null?void 0:i.startsWith("image/")}),r=await this._buildReportPdf(o,t),l=new Blob([r],{type:"application/pdf"});this._triggerDownload(l,`${this.safeRef(o)}_report.pdf`)}catch(t){alert("Failed to generate PDF: "+t.message)}finally{this.generatingPdf=null}},async _loadLibraries(){window.jspdf||await this._loadScript("https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"),window.JSZip||await this._loadScript("https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js")},_loadScript(o){return new Promise((t,r)=>{if(document.querySelector(`script[src="${o}"]`)){t();return}const l=document.createElement("script");l.src=o,l.onload=t,l.onerror=r,document.head.appendChild(l)})},async _buildReportPdf(o,t=[]){const r=o.entityType||o.entity_type;return r==="drill"?this._buildDrillPdf(o,t):r==="incident"?this._buildIncidentPdf(o,t):this._buildManualPdf(o,t)},async _buildDrillPdf(o,t=[]){var x,F;const{jsPDF:r}=window.jspdf,l=new r({orientation:"portrait",unit:"mm",format:"a4"}),n=210,i=15,s=n-i*2;let a=0;const c=(f=10)=>{a+f>275&&(l.addPage(),a=20)},y=f=>{c(12),l.setFillColor(26,54,107),l.rect(i,a,s,7,"F"),l.setTextColor(255,255,255),l.setFontSize(8.5),l.setFont("helvetica","bold"),l.text(f.toUpperCase(),i+3,a+5),a+=10,l.setTextColor(30,30,30)},w=(f,E,u=68)=>{c(7),l.setFontSize(9),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text(f,i+2,a),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(":",i+u-6,a);const B=l.splitTextToSize(String(E||"—"),s-u-4);l.text(B,i+u,a),a+=Math.max(B.length*5,5)+2};l.setFillColor(26,54,107),l.rect(0,0,n,24,"F"),l.setDrawColor(255,200,50),l.setLineWidth(1.2),l.line(i,23.4,n-i,23.4),l.setTextColor(255,255,255),l.setFontSize(14),l.setFont("helvetica","bold"),l.text("EMERGENCY DRILL REPORT",n/2,10,{align:"center"}),l.setFontSize(8),l.setFont("helvetica","normal"),l.setTextColor(200,215,240),l.text("Quality, Health, Safety & Environment Management System",n/2,17,{align:"center"}),a=30,o.entityRef&&(l.setFillColor(240,245,255),l.roundedRect(n-i-44,26,44,8,2,2,"F"),l.setTextColor(26,54,107),l.setFontSize(8),l.setFont("helvetica","bold"),l.text(o.entityRef,n-i-2,31,{align:"right"}),l.setTextColor(30,30,30)),l.setDrawColor(180,190,210),l.setLineWidth(.4),l.rect(i,a,s,28,"S"),l.line(i+s/2,a,i+s/2,a+28),l.line(i,a+14,i+s/2,a+14),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("VESSEL:",i+3,a+6),l.setFont("helvetica","bold"),l.setTextColor(20,20,20),l.setFontSize(10),l.text(String(o.vessel||"—").toUpperCase(),i+22,a+6),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("DATE / PLACE:",i+3,a+20),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(`${o.date||"—"} / ${o.vessel||"—"}`,i+33,a+20);const N=i+s/2+3;l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("KIND OF DRILL:",N,a+6),l.setFontSize(11),l.setFont("helvetica","bold"),l.setTextColor(26,54,107),l.text(String(o.entity_subtype||"—").toUpperCase(),N,a+16),l.setFontSize(7.5),l.setFont("helvetica","italic"),l.setTextColor(120,120,120),l.text("RELEVANT IMAGES/NOTES ARE ATTACHED",N,a+23),a+=32,y("Drill Details"),w("Drill Master / Conducted By",o.entity_creator),w("Duration",o.entity_duration),w("Objectives",o.entity_objectives),w("Submitted By",o.submittedBy),w("Submitted At",this.formatDate(o.submittedAt)),a+=2;const D=o.entity_participants||0;y(`Crew Participation — ${D} member${D!==1?"s":""} participated`);const _=(()=>{const f=(o.findings||"").trim();if(/^CREW:/i.test(f))return f.replace(/^CREW:\s*/i,"").split(/\n\n/)[0].split(/[\n,]+/).map(B=>B.trim()).filter(Boolean);const E=[];return o.entity_creator&&E.push(`${o.entity_creator} (Drill Master)`),o.submittedBy&&o.submittedBy!==o.entity_creator&&E.push(`${o.submittedBy} (Reporter)`),E})();c(14);const C=i,p=12,h=i+p,b=s-p;l.setFillColor(235,240,250),l.rect(C,a,s,7,"F"),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(26,54,107),l.text("NO.",C+2,a+5),l.text("NAME / RANK",h+2,a+5),a+=8,_.length>0?_.forEach((f,E)=>{c(7),E%2===0&&(l.setFillColor(249,250,252),l.rect(C,a-1,s,7,"F")),l.setFontSize(8.5),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.text(String(E+1),C+2,a+4),l.text(l.splitTextToSize(f,b-4)[0],h+2,a+4),a+=7}):(c(8),l.setFontSize(8.5),l.setFont("helvetica","italic"),l.setTextColor(150,150,150),l.text(`${D} crew members participated — attach signed crew list with participants' signatures`,h+2,a+4),a+=8),a+=4,y("Comments");const k=["Is the reaction of crew members satisfactory?","Is the equipment functioning properly?","Is the crew properly trained and ready?","Was debriefing conducted on completion of drill?","Is time log of various activities marked on checklist?"],d=(()=>{const f=o.drill_checklist||o.drillChecklist;if(Array.isArray(f))return f;try{return JSON.parse(f)}catch{return[!0,!0,!0,!0,!0]}})();k.forEach((f,E)=>{c(9);const u=d[E]!==!1;l.setFontSize(8.5),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.text(`${E+1}. ${f}`,i+3,a+5),u?(l.setFillColor(212,237,218),l.roundedRect(n-i-18,a+1,18,6,2,2,"F"),l.setTextColor(21,87,36),l.setFont("helvetica","bold"),l.setFontSize(7.5),l.text("YES",n-i-9,a+5.5,{align:"center"})):(l.setFillColor(248,215,218),l.roundedRect(n-i-18,a+1,18,6,2,2,"F"),l.setTextColor(114,28,36),l.setFont("helvetica","bold"),l.setFontSize(7.5),l.text("NO",n-i-9,a+5.5,{align:"center"})),a+=9}),a+=3;const m=(()=>{const f=(o.findings||"").trim();return/^CREW:/i.test(f)?f.split(/\n\n+/).slice(1).join(`
2
2
 
3
- `).trim():f})();m&&(y("Drill Scenario & Findings"),c(10),l.setFontSize(9),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.splitTextToSize(m,n-6).forEach(E=>{c(6),l.text(E,s+3,a),a+=5.5}),a+=4),o.correctiveActions&&(y("Suggestions for Improvement & Corrective Actions"),c(10),l.setFontSize(9),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.splitTextToSize(o.correctiveActions,n-6).forEach(E=>{c(6),l.text(E,s+3,a),a+=5.5}),a+=4),c(22),y("Remarks"),l.setDrawColor(180,190,210),l.setLineWidth(.3),l.rect(s,a,n,16,"S"),l.setFontSize(8.5),l.setFont("helvetica","italic"),l.setTextColor(140,140,140),l.text("Drill carried out satisfactorily.",s+3,a+8),a+=20;for(const f of t)try{let E;if(f.file instanceof File?E=await this._fileToDataUrl(f.file):f.publicUrl&&(E=await this._fetchImageAsDataUrl(f.publicUrl)),!E)continue;c(30),y("Attachment: "+f.name);const S=l.getImageProperties(E),B=Math.min(n/S.width,80/S.height),gm=S.width*B,T=S.height*B;c(T+5),l.addImage(E,((u=(x=f.type)==null?void 0:x.split("/")[1])==null?void 0:u.toUpperCase())||"JPEG",s,a,gm,T),a+=T+8}catch(E){console.warn("Could not embed image",f.name,E)}const g=l.getNumberOfPages();for(let f=1;f<=g;f++)l.setPage(f),l.setFillColor(26,54,107),l.rect(0,287,i,10,"F"),l.setTextColor(180,200,240),l.setFontSize(7.5),l.setFont("helvetica","normal"),l.text(`Emergency Drill Report · Generated ${new Date().toLocaleDateString("en-GB")} · Page ${f} of ${g}`,s,293),o.entityRef&&l.text(o.entityRef,i-s,293,{align:"right"});return l.output("arraybuffer")},async _buildIncidentPdf(o,t=[]){var _,C;const{jsPDF:r}=window.jspdf,l=new r({orientation:"portrait",unit:"mm",format:"a4"}),i=210,s=15,n=i-s*2;let a=0;const c=(p=10)=>{a+p>275&&(l.addPage(),a=20)},y=(p,h,b=18)=>{const k=h?l.splitTextToSize(String(h),n-6):[],d=k.length*5.5,m=Math.max(b,d+14);c(m+4),l.setDrawColor(140,150,165),l.setLineWidth(.35),l.rect(s,a,n,m,"S"),l.setFontSize(7.5),l.setFont("helvetica","bold"),l.setTextColor(70,80,100);const g=l.splitTextToSize(p.toUpperCase(),n-6);g.forEach((u,f)=>l.text(u,s+3,a+5+f*4));const x=g.length*4+2;if(l.setDrawColor(200,208,220),l.setLineWidth(.2),l.line(s+1,a+x+2,s+n-1,a+x+2),k.length>0){l.setFontSize(9.5),l.setFont("helvetica","normal"),l.setTextColor(20,20,20);let u=a+x+7;k.forEach(f=>{l.text(f,s+3,u),u+=5.5})}a+=m+3};l.setFillColor(26,54,107),l.rect(0,0,i,16,"F"),l.setTextColor(255,255,255),l.setFontSize(12),l.setFont("helvetica","bold");const w=(o.entity_subtype||o.entityType||"INCIDENT").toUpperCase()+" REPORT";l.text(w,s,10),l.setFontSize(7.5),l.setFont("helvetica","normal"),l.setTextColor(200,215,240),l.text(`Ref: ${o.entityRef||"—"}`,i-s,8,{align:"right"}),l.text(`Date: ${o.date||"—"}`,i-s,13,{align:"right"}),a=20,l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("FORM NUMBER:",s,a+4),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(o.entityRef||"—",s+30,a+4),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("SUBMITTED BY:",i/2,a+4),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(o.submittedBy||"—",i/2+28,a+4),a+=10;const N=(n-2)/2;l.setDrawColor(140,150,165),l.setLineWidth(.35),l.rect(s,a,N,14,"S"),l.rect(s+N+2,a,N,14,"S"),l.setFontSize(7.5),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("VESSEL NAME",s+3,a+5),l.text("SEVERITY / TYPE",s+N+5,a+5),l.setFontSize(10),l.setFont("helvetica","bold"),l.setTextColor(20,20,20),l.text(String(o.vessel||"—"),s+3,a+12),l.text(`${o.entity_subtype||"—"} · ${o.severity||o.entity_subtype||"—"}`,s+N+5,a+12),a+=18,l.setDrawColor(140,150,165),l.setLineWidth(.35),l.rect(s,a,N,10,"S"),l.rect(s+N+2,a,N,10,"S"),l.setFontSize(7.5),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("MANAGEMENT OFFICE",s+3,a+4),l.text("DATE",s+N+5,a+4),l.setFontSize(9),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text("—",s+3,a+9),l.text(o.date||"—",s+N+5,a+9),a+=14,y("Description of Event",o.findings,24),y(`Possible Consequences
3
+ `).trim():f})();m&&(y("Drill Scenario & Findings"),c(10),l.setFontSize(9),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.splitTextToSize(m,s-6).forEach(E=>{c(6),l.text(E,i+3,a),a+=5.5}),a+=4),o.correctiveActions&&(y("Suggestions for Improvement & Corrective Actions"),c(10),l.setFontSize(9),l.setFont("helvetica","normal"),l.setTextColor(30,30,30),l.splitTextToSize(o.correctiveActions,s-6).forEach(E=>{c(6),l.text(E,i+3,a),a+=5.5}),a+=4),c(22),y("Remarks"),l.setDrawColor(180,190,210),l.setLineWidth(.3),l.rect(i,a,s,16,"S"),l.setFontSize(8.5),l.setFont("helvetica","italic"),l.setTextColor(140,140,140),l.text("Drill carried out satisfactorily.",i+3,a+8),a+=20;for(const f of t)try{let E;if(f.file instanceof File?E=await this._fileToDataUrl(f.file):f.publicUrl&&(E=await this._fetchImageAsDataUrl(f.publicUrl)),!E)continue;c(30),y("Attachment: "+f.name);const u=l.getImageProperties(E),B=Math.min(s/u.width,80/u.height),gm=u.width*B,T=u.height*B;c(T+5),l.addImage(E,((F=(x=f.type)==null?void 0:x.split("/")[1])==null?void 0:F.toUpperCase())||"JPEG",i,a,gm,T),a+=T+8}catch(E){console.warn("Could not embed image",f.name,E)}const g=l.getNumberOfPages();for(let f=1;f<=g;f++)l.setPage(f),l.setFillColor(26,54,107),l.rect(0,287,n,10,"F"),l.setTextColor(180,200,240),l.setFontSize(7.5),l.setFont("helvetica","normal"),l.text(`Emergency Drill Report · Generated ${new Date().toLocaleDateString("en-GB")} · Page ${f} of ${g}`,i,293),o.entityRef&&l.text(o.entityRef,n-i,293,{align:"right"});return l.output("arraybuffer")},async _buildIncidentPdf(o,t=[]){var _,C;const{jsPDF:r}=window.jspdf,l=new r({orientation:"portrait",unit:"mm",format:"a4"}),n=210,i=15,s=n-i*2;let a=0;const c=(p=10)=>{a+p>275&&(l.addPage(),a=20)},y=(p,h,b=18)=>{const k=h?l.splitTextToSize(String(h),s-6):[],d=k.length*5.5,m=Math.max(b,d+14);c(m+4),l.setDrawColor(140,150,165),l.setLineWidth(.35),l.rect(i,a,s,m,"S"),l.setFontSize(7.5),l.setFont("helvetica","bold"),l.setTextColor(70,80,100);const g=l.splitTextToSize(p.toUpperCase(),s-6);g.forEach((F,f)=>l.text(F,i+3,a+5+f*4));const x=g.length*4+2;if(l.setDrawColor(200,208,220),l.setLineWidth(.2),l.line(i+1,a+x+2,i+s-1,a+x+2),k.length>0){l.setFontSize(9.5),l.setFont("helvetica","normal"),l.setTextColor(20,20,20);let F=a+x+7;k.forEach(f=>{l.text(f,i+3,F),F+=5.5})}a+=m+3};l.setFillColor(26,54,107),l.rect(0,0,n,16,"F"),l.setTextColor(255,255,255),l.setFontSize(12),l.setFont("helvetica","bold");const w=(o.entity_subtype||o.entityType||"INCIDENT").toUpperCase()+" REPORT";l.text(w,i,10),l.setFontSize(7.5),l.setFont("helvetica","normal"),l.setTextColor(200,215,240),l.text(`Ref: ${o.entityRef||"—"}`,n-i,8,{align:"right"}),l.text(`Date: ${o.date||"—"}`,n-i,13,{align:"right"}),a=20,l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("FORM NUMBER:",i,a+4),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(o.entityRef||"—",i+30,a+4),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("SUBMITTED BY:",n/2,a+4),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text(o.submittedBy||"—",n/2+28,a+4),a+=10;const N=(s-2)/2;l.setDrawColor(140,150,165),l.setLineWidth(.35),l.rect(i,a,N,14,"S"),l.rect(i+N+2,a,N,14,"S"),l.setFontSize(7.5),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("VESSEL NAME",i+3,a+5),l.text("SEVERITY / TYPE",i+N+5,a+5),l.setFontSize(10),l.setFont("helvetica","bold"),l.setTextColor(20,20,20),l.text(String(o.vessel||"—"),i+3,a+12),l.text(`${o.entity_subtype||"—"} · ${o.severity||o.entity_subtype||"—"}`,i+N+5,a+12),a+=18,l.setDrawColor(140,150,165),l.setLineWidth(.35),l.rect(i,a,N,10,"S"),l.rect(i+N+2,a,N,10,"S"),l.setFontSize(7.5),l.setFont("helvetica","bold"),l.setTextColor(80,90,110),l.text("MANAGEMENT OFFICE",i+3,a+4),l.text("DATE",i+N+5,a+4),l.setFontSize(9),l.setFont("helvetica","normal"),l.setTextColor(20,20,20),l.text("—",i+3,a+9),l.text(o.date||"—",i+N+5,a+9),a+=14,y("Description of Event",o.findings,24),y(`Possible Consequences
4
4
  (e.g. Personal injury, damage, collision, grounding, fire, pollution etc.)`,o.inc_consequences||null,18),y(`Relevant Factors / Conditions Surrounding the Event
5
5
  (e.g. weather, lighting etc.)`,o.inc_factors||null,18),y("Immediate Action Taken",o.inc_immediate_action||null,16),y(`Direct Cause
6
6
  (e.g. failure to follow procedures, inadequate or defective equipment etc.)`,o.inc_direct_cause||null,18),y(`Root Cause
7
- (e.g. lack of training, personal factors, job factors, control management factors, instructions not clear etc.)`,o.inc_root_cause||null,18),y("Action Taken on Board to Avoid Re-occurrence",o.correctiveActions||null,18),y("Any Other Remarks",o.inc_remarks||null,16);for(const p of t)try{let h;if(p.file instanceof File?h=await this._fileToDataUrl(p.file):p.publicUrl&&(h=await this._fetchImageAsDataUrl(p.publicUrl)),!h)continue;c(30),l.setFillColor(235,240,250),l.rect(s,a,n,7,"F"),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(26,54,107),l.text("ATTACHMENT: "+p.name,s+3,a+5),a+=10;const b=l.getImageProperties(h),k=Math.min(n/b.width,80/b.height),d=b.width*k,m=b.height*k;c(m+5),l.addImage(h,((C=(_=p.type)==null?void 0:_.split("/")[1])==null?void 0:C.toUpperCase())||"JPEG",s,a,d,m),a+=m+8}catch(h){console.warn("Could not embed image",p.name,h)}c(14),a+=4,l.setFontSize(8.5),l.setFont("helvetica","italic"),l.setTextColor(100,110,130),l.text("Closed out on board / Office support required (delete as applicable)",s,a),a+=8;const D=l.getNumberOfPages();for(let p=1;p<=D;p++)l.setPage(p),l.setFillColor(26,54,107),l.rect(0,287,i,10,"F"),l.setTextColor(180,200,240),l.setFontSize(7.5),l.setFont("helvetica","normal"),l.text(`Incident Report · Generated ${new Date().toLocaleDateString("en-GB")} · Page ${p} of ${D}`,s,293),o.entityRef&&l.text(o.entityRef,i-s,293,{align:"right"});return l.output("arraybuffer")},async _buildManualPdf(o,t=[]){var _,C;const{jsPDF:r}=window.jspdf,l=new r({orientation:"portrait",unit:"mm",format:"a4"}),i=18,s=210,n=s-i*2;let a=0;l.setFillColor(30,60,114),l.rect(0,0,s,28,"F"),l.setTextColor(255,255,255),l.setFontSize(16),l.setFont("helvetica","bold"),l.text("QHSE REPORT",i,11),l.setFontSize(9),l.setFont("helvetica","normal"),l.text(this.reportTypeLabel(o),i,18),o.entityRef&&(l.setFontSize(10),l.setFont("helvetica","bold"),l.text(o.entityRef,s-i,18,{align:"right"})),a=36,l.setTextColor(30,60,114),l.setFontSize(13),l.setFont("helvetica","bold");const c=l.splitTextToSize(o.title,n);l.text(c,i,a),a+=c.length*6+4,l.setDrawColor(200,210,230),l.line(i,a,s-i,a),a+=6;const y=[["Submitted By",o.submittedBy||"—"],["Date",o.date||"—"],["Vessel / Location",o.vessel||"—"],["Submitted At",this.formatDate(o.submittedAt)]];o.manualCategory&&y.splice(2,0,["Category",o.manualCategory]);const w=n/2;y.forEach((p,h)=>{const b=h%2,k=Math.floor(h/2),d=i+b*w,m=a+k*10;l.setFontSize(9),l.setFont("helvetica","bold"),l.setTextColor(100,120,160),l.text(p[0].toUpperCase(),d,m),l.setFont("helvetica","normal"),l.setTextColor(40,40,40),l.text(String(p[1]),d,m+4.5)}),a+=Math.ceil(y.length/2)*10+6;const N=(p,h)=>{h&&(a>250&&(l.addPage(),a=20),l.setFillColor(240,245,255),l.roundedRect(i,a,n,7,1,1,"F"),l.setFont("helvetica","bold"),l.setFontSize(9),l.setTextColor(30,60,114),l.text(p.toUpperCase(),i+3,a+5),a+=10,l.setFont("helvetica","normal"),l.setFontSize(10),l.setTextColor(40,40,40),l.splitTextToSize(h,n).forEach(b=>{a>272&&(l.addPage(),a=20),l.text(b,i,a),a+=5.5}),a+=4)};N("Findings / Summary",o.findings),N("Corrective Actions",o.correctiveActions);for(const p of t)try{let h;if(p.file instanceof File?h=await this._fileToDataUrl(p.file):p.publicUrl&&(h=await this._fetchImageAsDataUrl(p.publicUrl)),!h)continue;a>220&&(l.addPage(),a=20),l.setFillColor(240,245,255),l.roundedRect(i,a,n,7,1,1,"F"),l.setFont("helvetica","bold"),l.setFontSize(9),l.setTextColor(30,60,114),l.text("ATTACHMENT: "+p.name,i+3,a+5),a+=10;const b=l.getImageProperties(h),k=Math.min(n/b.width,80/b.height),d=b.width*k,m=b.height*k;a+m>272&&(l.addPage(),a=20),l.addImage(h,((C=(_=p.type)==null?void 0:_.split("/")[1])==null?void 0:C.toUpperCase())||"JPEG",i,a,d,m),a+=m+8}catch(h){console.warn("Could not embed image",p.name,h)}const D=l.getNumberOfPages();for(let p=1;p<=D;p++)l.setPage(p),l.setFillColor(30,60,114),l.rect(0,287,s,10,"F"),l.setTextColor(180,200,240),l.setFontSize(8),l.setFont("helvetica","normal"),l.text(`Generated ${new Date().toLocaleDateString("en-GB")} · Page ${p} of ${D}`,i,293),o.entityRef&&l.text(o.entityRef,s-i,293,{align:"right"});return l.output("arraybuffer")},async _buildAndDownloadZip(o,t,r){const l=new window.JSZip,i=this.safeRef(o),s=l.folder(i);s.file(`${i}_report.pdf`,t);for(const a of r)try{let c;if(a.file instanceof File)c=await a.file.arrayBuffer();else if(a.publicUrl){const y=await fetch(a.publicUrl);if(!y.ok)throw new Error(`HTTP ${y.status}`);c=await y.arrayBuffer()}c&&s.file(a.name,c)}catch(c){console.warn(`Could not add ${a.name} to ZIP:`,c)}const n=await l.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:6}});this._triggerDownload(n,`${i}.zip`)},_triggerDownload(o,t){const r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(r),5e3)},_fileToDataUrl(o){return new Promise((t,r)=>{const l=new FileReader;l.onload=()=>t(l.result),l.onerror=r,l.readAsDataURL(o)})},async _fetchImageAsDataUrl(o){try{const t=await fetch(o);return this._fileToDataUrl(await t.blob())}catch{return null}},handleReportFileAttach(o){this.reportForm.files.push(...Array.from(o.target.files)),o.target.value=""},handleReportFileDrop(o){this.reportForm.files.push(...Array.from(o.dataTransfer.files))},removeReportFile(o){this.reportForm.files.splice(o,1)},requestCreateFolder(){this.newFolderName.trim()&&(this.$emit("folder-create-requested",this.newFolderName.trim()),this.newFolderName="",this.showNewFolderModal=!1,this.activeTab="folders")},selectFolder(o){this.selectedFolder=o,this.$refs.fileInput.click()},handleFileSelection(o){const t=Array.from(o.target.files);!this.selectedFolder||t.length===0||(this.$emit("files-add-requested",{folderId:this.selectedFolder.id,files:t.map(r=>({id:Date.now()+Math.random(),name:r.name,size:r.size,type:r.type,file:r,addedAt:new Date}))}),o.target.value="",this.selectedFolder=null)},toggleFolder(o){const t=this.expandedFolders.indexOf(o);t>-1?this.expandedFolders.splice(t,1):this.expandedFolders.push(o)},formatFileSize(o){if(!o)return"0 B";const t=1024,r=["B","KB","MB","GB"],l=Math.floor(Math.log(o)/Math.log(t));return Math.round(o/Math.pow(t,l)*100)/100+" "+r[l]},formatDate(o){return o?new Date(o).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}}},Oe={class:"reports-container"},Ue={key:0,class:"missing-banner"},je={class:"missing-banner-inner"},Ge={class:"missing-content"},He={key:0},We={class:"ref-chip"},Qe={key:1},Je={key:2},Ye={class:"page-header d-flex justify-content-between align-items-center"},Ze={class:"header-actions"},Ke={class:"btn-group-split"},$e={class:"tab-nav"},Xe={class:"tab-count"},ve={class:"tab-count drill"},et={class:"tab-count incident"},tt={class:"tab-count manual"},ot={class:"tab-count"},nt={key:0,class:"loading-container"},it={key:1},st={key:0,class:"report-cards"},lt=["onClick"],rt={class:"rc-ref"},at={class:"rc-title"},dt={class:"rc-meta"},ct={key:0,class:"rc-files"},mt=["onClick"],pt={class:"rc-actions"},ft=["onClick"],ht=["onClick","disabled"],gt={key:0,class:"spinner-xs"},yt={key:1,class:"bi bi-file-zip"},Et={key:1,class:"empty-state text-center"},Nt={class:"mt-3 text-muted"},bt={class:"text-muted"},Vt={key:0},kt={key:1},wt={key:2},Ct={key:3},Dt={key:2},_t={key:0},St={class:"section-heading"},Ft={class:"section-count"},ut={class:"folders-list"},Bt=["onClick"],xt={class:"af-icon-wrap"},Tt={class:"af-count-badge"},Rt={class:"af-meta"},At={class:"af-ref"},Pt={class:"af-title"},Mt={class:"af-sub"},It={class:"text-muted"},Lt={key:0,class:"text-muted"},qt={class:"af-actions"},zt=["onClick","disabled"],Ot={key:0,class:"spinner-xs"},Ut={key:1,class:"bi bi-file-zip"},jt={key:0,class:"af-contents"},Gt=["onClick"],Ht={class:"ffi-meta"},Wt={class:"ffi-name"},Qt={class:"ffi-acts"},Jt=["onClick"],Yt=["onClick","disabled"],Zt={key:0,class:"spinner-xs"},Kt={key:1,class:"bi bi-download"},$t={class:"ffi-meta"},Xt={class:"ffi-name"},vt={class:"ffi-sub"},eo={class:"ffi-acts"},to=["href"],oo={key:0,class:"ffi-empty"},no={class:"af-zip-row"},io=["onClick","disabled"],so={key:0},lo={key:1},ro={class:"af-zip-hint"},ao={class:"section-heading"},co={class:"section-count"},mo={class:"folders-list"},po=["onClick"],fo={class:"af-icon-wrap"},ho={class:"af-count-badge",style:{background:"#f0ad4e",color:"#664d03"}},go={class:"af-meta"},yo={class:"af-ref"},Eo={class:"af-sub"},No={class:"text-muted"},bo={class:"af-actions"},Vo=["onClick"],ko=["onClick"],wo={key:0,class:"af-contents"},Co={class:"ffi-meta"},Do={class:"ffi-name"},_o={class:"ffi-sub"},So={class:"ffi-acts"},Fo=["onClick"],uo={key:0,class:"ffi-empty"},Bo=["onClick"],xo={key:2,class:"empty-state text-center"},To={class:"modal-dialog modal-dialog-centered"},Ro={class:"modal-content"},Ao={class:"modal-header"},Po={class:"modal-body"},Mo={class:"modal-footer"},Io=["disabled"],Lo={class:"modal-dialog modal-dialog-centered modal-lg"},qo={class:"modal-content"},zo={class:"modal-header rpt-modal-header"},Oo={class:"modal-title"},Uo={key:0,class:"modal-type-toggle"},jo={class:"modal-body"},Go={key:0,class:"rpt-entity-box"},Ho={key:0,class:"prefilled-entity"},Wo={class:"text-muted ms-2"},Qo={key:1},Jo={label:"Missing Drill Reports"},Yo=["value"],Zo={label:"Missing Incident Reports"},Ko=["value"],$o={key:1,class:"input-row"},Xo={class:"form-group"},vo={class:"form-group"},en={key:2,class:"crew-hint"},tn={key:3,class:"drill-checklist-box"},on={class:"checklist-grid"},nn={class:"checklist-checkbox"},sn=["checked","onChange"],ln={class:"custom-check"},rn={class:"checklist-q"},an={class:"input-row mt-3"},dn={class:"form-group"},cn=["placeholder"],mn={class:"form-group"},pn={class:"input-row"},fn={class:"form-group"},hn={class:"form-group"},gn={class:"form-label fw-semibold"},yn={key:0,class:"form-hint"},En=["placeholder"],Nn={key:4,class:"incident-fields-box"},bn={class:"form-group"},Vn={class:"form-group"},kn={class:"form-group"},wn={class:"input-row",style:{"margin-bottom":"0"}},Cn={class:"form-group"},Dn={class:"form-group"},_n={class:"form-group"},Sn={class:"form-group",style:{"margin-bottom":"0"}},Fn={key:5,class:"form-group"},un={class:"form-group"},Bn={key:0,class:"attached-files"},xn=["onClick"],Tn={key:6,class:"zip-hint"},Rn={key:0},An={class:"modal-footer"},Pn=["disabled"],Mn={key:0},In={key:1},Ln={class:"modal-dialog modal-dialog-centered modal-lg"},qn={key:0,class:"modal-content"},zn={class:"modal-header rpt-modal-header"},On={class:"d-flex align-items-center gap-2"},Un={style:{color:"#fff"}},jn={class:"modal-body"},Gn={class:"view-grid"},Hn={class:"view-item"},Wn={class:"ref-mono"},Qn={class:"view-item"},Jn={key:0,class:"view-item"},Yn={class:"view-item"},Zn={class:"view-item"},Kn={key:1,class:"view-item"},$n={class:"view-item"},Xn={key:2,class:"view-item"},vn={key:3,class:"view-item"},ei={key:4,class:"view-item"},ti={key:5,class:"view-item"},oi={class:"view-section"},ni={class:"view-text"},ii={key:0,class:"view-section"},si={class:"view-text"},li={key:1,class:"view-section"},ri={class:"attached-files mt-1"},ai=["href"],di={class:"text-muted ms-1"},ci={class:"modal-footer"},mi=["disabled"],pi={key:0},fi={key:1};function hi(o,t,r,l,i,s){return e.openBlock(),e.createElementBlock("div",Oe,[e.createVNode(e.Transition,{name:"slide-down"},{default:e.withCtx(()=>[!i.bannerDismissed&&(r.pendingContext||r.missingReports.length>0)?(e.openBlock(),e.createElementBlock("div",Ue,[e.createElementVNode("div",je,[t[54]||(t[54]=e.createElementVNode("div",{class:"missing-icon"},[e.createElementVNode("i",{class:"bi bi-exclamation-triangle-fill"})],-1)),e.createElementVNode("div",Ge,[r.pendingContext?(e.openBlock(),e.createElementBlock("strong",He,[t[50]||(t[50]=e.createTextVNode(" Action Required — Report for ",-1)),e.createElementVNode("span",We,e.toDisplayString(r.pendingContext.entity_ref),1),t[51]||(t[51]=e.createTextVNode(" must be submitted ",-1))])):(e.openBlock(),e.createElementBlock("strong",Qe,e.toDisplayString(r.missingReports.length)+" report"+e.toDisplayString(r.missingReports.length>1?"s":"")+" awaiting submission ",1)),r.pendingContext?(e.openBlock(),e.createElementBlock("p",Je,e.toDisplayString(r.pendingContext.title),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{class:"btn btn-warning btn-sm fw-bold",onClick:t[0]||(t[0]=n=>s.openReportForm("qhse"))},t[52]||(t[52]=[e.createElementVNode("i",{class:"bi bi-pencil-square me-1"},null,-1),e.createTextVNode(" Submit Report ",-1)])),e.createElementVNode("button",{class:"btn-dismiss",onClick:t[1]||(t[1]=(...n)=>s.dismissBanner&&s.dismissBanner(...n)),title:"Dismiss"},t[53]||(t[53]=[e.createElementVNode("i",{class:"bi bi-x-lg"},null,-1)]))])])):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("div",Ye,[t[58]||(t[58]=e.createElementVNode("div",null,[e.createElementVNode("h4",{class:"page-title"},"Reports"),e.createElementVNode("p",{class:"page-subtitle"},"Document Management & QHSE Reports")],-1)),e.createElementVNode("div",Ze,[e.createElementVNode("div",Ke,[e.createElementVNode("button",{class:"btn btn-outline-primary",onClick:t[2]||(t[2]=n=>s.openReportForm("qhse"))},t[55]||(t[55]=[e.createElementVNode("i",{class:"bi bi-shield-check"},null,-1),e.createTextVNode(" QHSE Report ",-1)])),e.createElementVNode("button",{class:"btn btn-outline-secondary",onClick:t[3]||(t[3]=n=>s.openReportForm("manual"))},t[56]||(t[56]=[e.createElementVNode("i",{class:"bi bi-file-earmark-plus"},null,-1),e.createTextVNode(" Manual Report ",-1)])),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[4]||(t[4]=n=>i.showNewFolderModal=!0)},t[57]||(t[57]=[e.createElementVNode("i",{class:"bi bi-folder-plus"},null,-1),e.createTextVNode(" New Folder ",-1)]))])])]),e.createElementVNode("div",$e,[e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:i.activeTab==="all"}]),onClick:t[5]||(t[5]=n=>i.activeTab="all")},[t[59]||(t[59]=e.createTextVNode(" All Reports ",-1)),e.createElementVNode("span",Xe,e.toDisplayString(r.reports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:i.activeTab==="drill"}]),onClick:t[6]||(t[6]=n=>i.activeTab="drill")},[t[60]||(t[60]=e.createElementVNode("i",{class:"bi bi-people-fill me-1"},null,-1)),t[61]||(t[61]=e.createTextVNode("Drills ",-1)),e.createElementVNode("span",ve,e.toDisplayString(s.drillReports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:i.activeTab==="incident"}]),onClick:t[7]||(t[7]=n=>i.activeTab="incident")},[t[62]||(t[62]=e.createElementVNode("i",{class:"bi bi-exclamation-octagon-fill me-1"},null,-1)),t[63]||(t[63]=e.createTextVNode("Incidents ",-1)),e.createElementVNode("span",et,e.toDisplayString(s.incidentReports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:i.activeTab==="manual"}]),onClick:t[8]||(t[8]=n=>i.activeTab="manual")},[t[64]||(t[64]=e.createElementVNode("i",{class:"bi bi-file-earmark-text me-1"},null,-1)),t[65]||(t[65]=e.createTextVNode("Manual ",-1)),e.createElementVNode("span",tt,e.toDisplayString(s.manualReports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:i.activeTab==="folders"}]),onClick:t[9]||(t[9]=n=>i.activeTab="folders")},[t[66]||(t[66]=e.createElementVNode("i",{class:"bi bi-folder-fill me-1"},null,-1)),t[67]||(t[67]=e.createTextVNode("Folders ",-1)),e.createElementVNode("span",ot,e.toDisplayString(r.reports.length+r.folders.length),1)],2)]),r.isLoading?(e.openBlock(),e.createElementBlock("div",nt,t[68]||(t[68]=[e.createElementVNode("div",{class:"spinner"},null,-1),e.createElementVNode("p",null,"Loading reports…",-1)]))):e.createCommentVNode("",!0),i.activeTab!=="folders"&&!r.isLoading?(e.openBlock(),e.createElementBlock("div",it,[s.filteredReports.length>0?(e.openBlock(),e.createElementBlock("div",st,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.filteredReports,n=>{var a;return e.openBlock(),e.createElementBlock("div",{key:n.id,ref_for:!0,ref:"report-"+n.entityRef,class:e.normalizeClass(["report-card",{"report-card--highlighted":i.highlightedRef===n.entityRef}])},[e.createElementVNode("div",{class:e.normalizeClass(["rc-type-bar",s.reportTypeClass(n)])},null,2),e.createElementVNode("div",{class:e.normalizeClass(["rc-badge",s.reportTypeClass(n)])},e.toDisplayString(s.reportTypeLabel(n)),3),e.createElementVNode("div",{class:"rc-body",onClick:c=>s.viewReport(n)},[e.createElementVNode("strong",rt,e.toDisplayString(n.entityRef||((a=n.id)==null?void 0:a.slice(0,8).toUpperCase())),1),e.createElementVNode("span",at,e.toDisplayString(n.title),1),e.createElementVNode("span",dt,[t[69]||(t[69]=e.createElementVNode("i",{class:"bi bi-person-fill me-1"},null,-1)),e.createTextVNode(e.toDisplayString(n.submittedBy)+"  ·  ",1),t[70]||(t[70]=e.createElementVNode("i",{class:"bi bi-calendar3 me-1"},null,-1)),e.createTextVNode(e.toDisplayString(s.formatDate(n.submittedAt)),1)])],8,lt),s.getFilesForReport(n.id).length>0?(e.openBlock(),e.createElementBlock("div",ct,[t[71]||(t[71]=e.createElementVNode("i",{class:"bi bi-paperclip"},null,-1)),e.createTextVNode(" "+e.toDisplayString(s.getFilesForReport(n.id).length),1)])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:e.normalizeClass(["rc-folder-pill",s.reportTypeClass(n)]),onClick:e.withModifiers(c=>s.jumpToFolder(n),["stop"]),title:"View folder"},[t[72]||(t[72]=e.createElementVNode("i",{class:"bi bi-folder-fill me-1"},null,-1)),e.createTextVNode(" "+e.toDisplayString(n.entityRef||n.title),1)],10,mt),e.createElementVNode("div",pt,[e.createElementVNode("button",{class:"rc-btn rc-btn--view",onClick:c=>s.viewReport(n),title:"View"},t[73]||(t[73]=[e.createElementVNode("i",{class:"bi bi-eye"},null,-1)]),8,ft),e.createElementVNode("button",{class:"rc-btn rc-btn--download",onClick:c=>s.downloadReport(n),disabled:i.generatingPdf===n.id,title:"Download ZIP"},[i.generatingPdf===n.id?(e.openBlock(),e.createElementBlock("span",gt)):(e.openBlock(),e.createElementBlock("i",yt))],8,ht)])],2)}),128))])):e.createCommentVNode("",!0),s.filteredReports.length===0?(e.openBlock(),e.createElementBlock("div",Et,[t[74]||(t[74]=e.createElementVNode("i",{class:"bi bi-file-earmark-x",style:{"font-size":"3.5rem",color:"#ccc"}},null,-1)),e.createElementVNode("h5",Nt,"No "+e.toDisplayString(i.activeTab==="all"?"":i.activeTab)+" reports yet",1),e.createElementVNode("p",bt,[i.activeTab==="manual"?(e.openBlock(),e.createElementBlock("span",Vt,"Create a manual report using the button above")):i.activeTab==="drill"?(e.openBlock(),e.createElementBlock("span",kt,"Submit a report after logging a drill")):i.activeTab==="incident"?(e.openBlock(),e.createElementBlock("span",wt,"Submit a report after logging an incident")):(e.openBlock(),e.createElementBlock("span",Ct,"Submit a report or create a folder to get started"))])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),i.activeTab==="folders"&&!r.isLoading?(e.openBlock(),e.createElementBlock("div",Dt,[r.reports.length>0?(e.openBlock(),e.createElementBlock("div",_t,[e.createElementVNode("div",St,[t[75]||(t[75]=e.createElementVNode("i",{class:"bi bi-folder-symlink-fill text-primary me-1"},null,-1)),t[76]||(t[76]=e.createTextVNode(" Report Folders ",-1)),e.createElementVNode("span",Ft,e.toDisplayString(r.reports.length),1),t[77]||(t[77]=e.createElementVNode("span",{class:"section-hint"},"Auto-generated · one per submitted report",-1))]),e.createElementVNode("div",ut,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.reports,n=>{var a;return e.openBlock(),e.createElementBlock("div",{key:"af-"+n.id,ref_for:!0,ref:"folder-"+(n.entityRef||n.id),class:e.normalizeClass(["auto-folder-card",s.reportTypeClass(n),{"is-open":i.expandedFolders.includes("auto-"+n.id)}])},[e.createElementVNode("div",{class:"af-header",onClick:c=>s.toggleFolder("auto-"+n.id)},[e.createElementVNode("div",xt,[e.createElementVNode("i",{class:e.normalizeClass(["bi bi-folder-fill af-folder-icon","color--"+s.reportTypeClass(n)])},null,2),e.createElementVNode("span",Tt,e.toDisplayString(1+s.getFilesForReport(n.id).length),1)]),e.createElementVNode("div",Rt,[e.createElementVNode("span",At,e.toDisplayString(n.entityRef||((a=n.id)==null?void 0:a.slice(0,8).toUpperCase())),1),e.createElementVNode("span",Pt,e.toDisplayString(n.title),1),e.createElementVNode("div",Mt,[e.createElementVNode("span",{class:e.normalizeClass(["mini-badge",s.reportTypeClass(n)])},e.toDisplayString(s.reportTypeLabel(n)),3),e.createElementVNode("span",It,e.toDisplayString(s.formatDate(n.submittedAt)),1),s.getFilesForReport(n.id).length?(e.openBlock(),e.createElementBlock("span",Lt," · "+e.toDisplayString(s.getFilesForReport(n.id).length)+" attachment"+e.toDisplayString(s.getFilesForReport(n.id).length!==1?"s":""),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",qt,[e.createElementVNode("button",{class:"rc-btn rc-btn--download",onClick:e.withModifiers(c=>s.downloadReport(n),["stop"]),disabled:i.generatingPdf===n.id,title:"Download ZIP"},[i.generatingPdf===n.id?(e.openBlock(),e.createElementBlock("span",Ot)):(e.openBlock(),e.createElementBlock("i",Ut))],8,zt),e.createElementVNode("i",{class:e.normalizeClass(["bi chevron-icon",i.expandedFolders.includes("auto-"+n.id)?"bi-chevron-up":"bi-chevron-down"])},null,2)])],8,Bt),e.createVNode(e.Transition,{name:"folder-expand"},{default:e.withCtx(()=>[i.expandedFolders.includes("auto-"+n.id)?(e.openBlock(),e.createElementBlock("div",jt,[e.createElementVNode("div",{class:"ffi ffi--report",onClick:c=>s.viewReport(n)},[t[80]||(t[80]=e.createElementVNode("div",{class:"ffi-icon ffi-icon--pdf"},[e.createElementVNode("i",{class:"bi bi-file-earmark-pdf-fill"})],-1)),e.createElementVNode("div",Ht,[e.createElementVNode("span",Wt,e.toDisplayString(s.safeRef(n))+"_report.pdf",1),t[78]||(t[78]=e.createElementVNode("span",{class:"ffi-sub"},"Generated report sheet · click to preview",-1))]),e.createElementVNode("div",Qt,[e.createElementVNode("button",{class:"rc-btn rc-btn--view",onClick:e.withModifiers(c=>s.viewReport(n),["stop"]),title:"Preview"},t[79]||(t[79]=[e.createElementVNode("i",{class:"bi bi-eye"},null,-1)]),8,Jt),e.createElementVNode("button",{class:"rc-btn rc-btn--download",onClick:e.withModifiers(c=>s.downloadReportPdfOnly(n),["stop"]),disabled:i.generatingPdf===n.id+"-pdf",title:"Download PDF only"},[i.generatingPdf===n.id+"-pdf"?(e.openBlock(),e.createElementBlock("span",Zt)):(e.openBlock(),e.createElementBlock("i",Kt))],8,Yt)])],8,Gt),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.getFilesForReport(n.id),c=>(e.openBlock(),e.createElementBlock("div",{key:c.id,class:"ffi"},[e.createElementVNode("div",{class:e.normalizeClass(["ffi-icon",s.ffiIconClass(c)])},[e.createElementVNode("i",{class:e.normalizeClass(["bi",s.fileIcon(c.type)])},null,2)],2),e.createElementVNode("div",$t,[e.createElementVNode("span",Xt,e.toDisplayString(c.name),1),e.createElementVNode("span",vt,e.toDisplayString(s.formatFileSize(c.size)),1)]),e.createElementVNode("div",eo,[c.publicUrl?(e.openBlock(),e.createElementBlock("a",{key:0,href:c.publicUrl,target:"_blank",rel:"noopener",class:"rc-btn rc-btn--view",title:"Open"},t[81]||(t[81]=[e.createElementVNode("i",{class:"bi bi-box-arrow-up-right"},null,-1)]),8,to)):e.createCommentVNode("",!0)])]))),128)),s.getFilesForReport(n.id).length===0?(e.openBlock(),e.createElementBlock("div",oo,t[82]||(t[82]=[e.createElementVNode("i",{class:"bi bi-paperclip me-1"},null,-1),e.createTextVNode("No attachments — ZIP will contain the report PDF only ",-1)]))):e.createCommentVNode("",!0),e.createElementVNode("div",no,[e.createElementVNode("button",{class:"btn btn-sm btn-outline-primary",onClick:c=>s.downloadReport(n),disabled:i.generatingPdf===n.id},[i.generatingPdf===n.id?(e.openBlock(),e.createElementBlock("span",so,t[83]||(t[83]=[e.createElementVNode("span",{class:"spinner-xs me-1"},null,-1),e.createTextVNode("Building ZIP… ",-1)]))):(e.openBlock(),e.createElementBlock("span",lo,t[84]||(t[84]=[e.createElementVNode("i",{class:"bi bi-file-zip me-1"},null,-1),e.createTextVNode("Download all as ZIP ",-1)])))],8,io),e.createElementVNode("span",ro,e.toDisplayString(s.safeRef(n))+".zip · report PDF"+e.toDisplayString(s.getFilesForReport(n.id).length?" + "+s.getFilesForReport(n.id).length+" file(s)":""),1)])])):e.createCommentVNode("",!0)]),_:2},1024)],2)}),128))])])):e.createCommentVNode("",!0),r.folders.length>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass({"mt-4":r.reports.length>0})},[e.createElementVNode("div",ao,[t[85]||(t[85]=e.createElementVNode("i",{class:"bi bi-folder-plus text-warning me-1"},null,-1)),t[86]||(t[86]=e.createTextVNode(" Custom Folders ",-1)),e.createElementVNode("span",co,e.toDisplayString(r.folders.length),1)]),e.createElementVNode("div",mo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.folders,n=>(e.openBlock(),e.createElementBlock("div",{key:"uf-"+n.id,class:e.normalizeClass(["user-folder-card",{"is-open":i.expandedFolders.includes("user-"+n.id)}])},[e.createElementVNode("div",{class:"af-header",onClick:a=>s.toggleFolder("user-"+n.id)},[e.createElementVNode("div",fo,[t[87]||(t[87]=e.createElementVNode("i",{class:"bi bi-folder-fill af-folder-icon color--user"},null,-1)),e.createElementVNode("span",ho,e.toDisplayString(n.files.length),1)]),e.createElementVNode("div",go,[e.createElementVNode("span",yo,e.toDisplayString(n.name),1),e.createElementVNode("span",Eo,[e.createElementVNode("span",No,e.toDisplayString(n.files.length)+" file"+e.toDisplayString(n.files.length!==1?"s":""),1)])]),e.createElementVNode("div",bo,[e.createElementVNode("button",{class:"rc-btn",style:{color:"#6f42c1"},onClick:e.withModifiers(a=>s.selectFolder(n),["stop"]),title:"Add Files"},t[88]||(t[88]=[e.createElementVNode("i",{class:"bi bi-file-earmark-plus"},null,-1)]),8,Vo),e.createElementVNode("button",{class:"rc-btn rc-btn--danger",onClick:e.withModifiers(a=>o.$emit("folder-delete-requested",n.id),["stop"]),title:"Delete"},t[89]||(t[89]=[e.createElementVNode("i",{class:"bi bi-trash"},null,-1)]),8,ko),e.createElementVNode("i",{class:e.normalizeClass(["bi chevron-icon",i.expandedFolders.includes("user-"+n.id)?"bi-chevron-up":"bi-chevron-down"])},null,2)])],8,po),e.createVNode(e.Transition,{name:"folder-expand"},{default:e.withCtx(()=>[i.expandedFolders.includes("user-"+n.id)?(e.openBlock(),e.createElementBlock("div",wo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.files,a=>(e.openBlock(),e.createElementBlock("div",{key:a.id,class:"ffi"},[e.createElementVNode("div",{class:e.normalizeClass(["ffi-icon",s.ffiIconClass(a)])},[e.createElementVNode("i",{class:e.normalizeClass(["bi",s.fileIcon(a.type)])},null,2)],2),e.createElementVNode("div",Co,[e.createElementVNode("span",Do,e.toDisplayString(a.name),1),e.createElementVNode("span",_o,e.toDisplayString(s.formatFileSize(a.size)),1)]),e.createElementVNode("div",So,[e.createElementVNode("button",{class:"rc-btn rc-btn--danger",onClick:c=>o.$emit("file-remove-requested",{folderId:n.id,fileId:a.id}),title:"Remove"},t[90]||(t[90]=[e.createElementVNode("i",{class:"bi bi-x-circle"},null,-1)]),8,Fo)])]))),128)),n.files.length===0?(e.openBlock(),e.createElementBlock("div",uo,[t[92]||(t[92]=e.createElementVNode("i",{class:"bi bi-inbox me-1"},null,-1)),t[93]||(t[93]=e.createTextVNode("Empty folder ",-1)),e.createElementVNode("button",{class:"btn btn-sm btn-outline-secondary ms-2",onClick:a=>s.selectFolder(n)},t[91]||(t[91]=[e.createElementVNode("i",{class:"bi bi-file-earmark-plus me-1"},null,-1),e.createTextVNode("Add Files ",-1)]),8,Bo)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),_:2},1024)],2))),128))])],2)):e.createCommentVNode("",!0),r.reports.length===0&&r.folders.length===0?(e.openBlock(),e.createElementBlock("div",xo,[t[95]||(t[95]=e.createElementVNode("i",{class:"bi bi-folder2-open",style:{"font-size":"3.5rem",color:"#ccc"}},null,-1)),t[96]||(t[96]=e.createElementVNode("h5",{class:"mt-3 text-muted"},"No folders yet",-1)),t[97]||(t[97]=e.createElementVNode("p",{class:"text-muted"},"Each submitted report auto-creates a folder here. You can also create custom folders.",-1)),e.createElementVNode("button",{class:"btn btn-primary mt-2",onClick:t[10]||(t[10]=n=>i.showNewFolderModal=!0)},t[94]||(t[94]=[e.createElementVNode("i",{class:"bi bi-folder-plus me-1"},null,-1),e.createTextVNode(" New Folder ",-1)]))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["modal",{show:i.showNewFolderModal}]),onClick:t[16]||(t[16]=e.withModifiers(n=>i.showNewFolderModal=!1,["self"]))},[e.createElementVNode("div",To,[e.createElementVNode("div",Ro,[e.createElementVNode("div",Ao,[t[98]||(t[98]=e.createElementVNode("h5",{class:"modal-title"},[e.createElementVNode("i",{class:"bi bi-folder-plus me-2"}),e.createTextVNode("Create New Folder")],-1)),e.createElementVNode("button",{type:"button",class:"btn-close",onClick:t[11]||(t[11]=n=>i.showNewFolderModal=!1)})]),e.createElementVNode("div",Po,[t[99]||(t[99]=e.createElementVNode("label",{class:"form-label"},"Folder Name",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[12]||(t[12]=n=>i.newFolderName=n),onKeyup:t[13]||(t[13]=e.withKeys((...n)=>s.requestCreateFolder&&s.requestCreateFolder(...n),["enter"])),placeholder:"e.g., Q1 2025 Drills"},null,544),[[e.vModelText,i.newFolderName]])]),e.createElementVNode("div",Mo,[e.createElementVNode("button",{type:"button",class:"btn btn-secondary",onClick:t[14]||(t[14]=n=>i.showNewFolderModal=!1)},"Cancel"),e.createElementVNode("button",{type:"button",class:"btn btn-primary",onClick:t[15]||(t[15]=(...n)=>s.requestCreateFolder&&s.requestCreateFolder(...n)),disabled:!i.newFolderName.trim()},"Create Folder",8,Io)])])])],2),e.createElementVNode("div",{class:e.normalizeClass(["modal",{show:i.showReportModal}]),onClick:t[43]||(t[43]=e.withModifiers((...n)=>s.closeReportForm&&s.closeReportForm(...n),["self"]))},[e.createElementVNode("div",Lo,[e.createElementVNode("div",qo,[e.createElementVNode("div",zo,[e.createElementVNode("h5",Oo,[e.createElementVNode("i",{class:e.normalizeClass(i.reportForm.report_type==="manual"?"bi bi-file-earmark-text me-2":"bi bi-shield-check me-2")},null,2),e.createTextVNode(" "+e.toDisplayString(i.reportForm.report_type==="manual"?"New Manual Report":"Submit QHSE Report"),1)]),r.pendingContext?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Uo,[e.createElementVNode("button",{class:e.normalizeClass(["type-toggle-btn",{active:i.reportForm.report_type==="qhse"}]),onClick:t[17]||(t[17]=n=>i.reportForm.report_type="qhse")},t[100]||(t[100]=[e.createElementVNode("i",{class:"bi bi-shield-check me-1"},null,-1),e.createTextVNode("QHSE ",-1)]),2),e.createElementVNode("button",{class:e.normalizeClass(["type-toggle-btn",{active:i.reportForm.report_type==="manual"}]),onClick:t[18]||(t[18]=n=>i.reportForm.report_type="manual")},t[101]||(t[101]=[e.createElementVNode("i",{class:"bi bi-file-earmark-text me-1"},null,-1),e.createTextVNode("Manual ",-1)]),2)])),e.createElementVNode("button",{type:"button",class:"btn-close btn-close-white",onClick:t[19]||(t[19]=(...n)=>s.closeReportForm&&s.closeReportForm(...n))})]),e.createElementVNode("div",jo,[i.reportForm.report_type==="qhse"?(e.openBlock(),e.createElementBlock("div",Go,[t[105]||(t[105]=e.createElementVNode("label",{class:"form-label fw-semibold"},[e.createElementVNode("i",{class:"bi bi-link-45deg me-1"}),e.createTextVNode("Link to Drill / Incident")],-1)),i.reportForm.entity_ref&&i.reportForm.entity_type?(e.openBlock(),e.createElementBlock("div",Ho,[e.createElementVNode("span",{class:e.normalizeClass(["entity-chip",i.reportForm.entity_type])},e.toDisplayString(i.reportForm.entity_type==="drill"?"DRILL":"INCIDENT"),3),e.createElementVNode("strong",null,e.toDisplayString(i.reportForm.entity_ref),1),e.createElementVNode("span",Wo,e.toDisplayString(i.reportForm.entity_label),1),e.createElementVNode("button",{class:"btn btn-link btn-sm text-danger ms-auto",onClick:t[20]||(t[20]=(...n)=>s.clearEntityLink&&s.clearEntityLink(...n))},t[102]||(t[102]=[e.createElementVNode("i",{class:"bi bi-x-circle"},null,-1),e.createTextVNode(" Clear",-1)]))])):(e.openBlock(),e.createElementBlock("div",Qo,[e.withDirectives(e.createElementVNode("select",{class:"form-control","onUpdate:modelValue":t[21]||(t[21]=n=>i.reportForm.selectedMissing=n),onChange:t[22]||(t[22]=(...n)=>s.applyMissingSelection&&s.applyMissingSelection(...n))},[t[103]||(t[103]=e.createElementVNode("option",{value:""},"— Select a missing report (optional) —",-1)),e.createElementVNode("optgroup",Jo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.missingReports.filter(n=>n.entity_type==="drill"),n=>(e.openBlock(),e.createElementBlock("option",{key:n.entity_id,value:JSON.stringify(n)},e.toDisplayString(n.entity_ref)+" — "+e.toDisplayString(n.label),9,Yo))),128))]),e.createElementVNode("optgroup",Zo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.missingReports.filter(n=>n.entity_type==="incident"),n=>(e.openBlock(),e.createElementBlock("option",{key:n.entity_id,value:JSON.stringify(n)},e.toDisplayString(n.entity_ref)+" — "+e.toDisplayString(n.label),9,Ko))),128))])],544),[[e.vModelSelect,i.reportForm.selectedMissing]]),t[104]||(t[104]=e.createElementVNode("small",{class:"text-muted"},"Linking will mark the drill / incident as reported.",-1))]))])):e.createCommentVNode("",!0),i.reportForm.report_type==="manual"?(e.openBlock(),e.createElementBlock("div",$o,[e.createElementVNode("div",Xo,[t[107]||(t[107]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Report Category",-1)),e.withDirectives(e.createElementVNode("select",{class:"form-control","onUpdate:modelValue":t[23]||(t[23]=n=>i.reportForm.manual_category=n)},t[106]||(t[106]=[e.createElementVNode("option",null,"General",-1),e.createElementVNode("option",null,"Maintenance",-1),e.createElementVNode("option",null,"Safety Observation",-1),e.createElementVNode("option",null,"Environmental",-1),e.createElementVNode("option",null,"Audit",-1),e.createElementVNode("option",null,"Training",-1),e.createElementVNode("option",null,"Other",-1)]),512),[[e.vModelSelect,i.reportForm.manual_category]])]),e.createElementVNode("div",vo,[t[108]||(t[108]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Reference Number",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[24]||(t[24]=n=>i.reportForm.manual_ref=n),placeholder:"e.g. RPT-2025-001"},null,512),[[e.vModelText,i.reportForm.manual_ref]])])])):e.createCommentVNode("",!0),i.reportForm.entity_type==="drill"?(e.openBlock(),e.createElementBlock("div",en,[t[112]||(t[112]=e.createElementVNode("i",{class:"bi bi-info-circle-fill me-1"},null,-1)),e.createElementVNode("span",null,[t[109]||(t[109]=e.createElementVNode("strong",null,"Crew list tip:",-1)),t[110]||(t[110]=e.createTextVNode(" Start your Findings with ",-1)),t[111]||(t[111]=e.createElementVNode("code",null,"CREW: Name (Rank), Name (Rank), …",-1)),e.createTextVNode(" to generate a named crew participation table in the PDF. Otherwise the PDF will show the total count ("+e.toDisplayString(i.reportForm.entity_participants||0)+" members) with a note to attach the signed list. ",1)])])):e.createCommentVNode("",!0),i.reportForm.entity_type==="drill"?(e.openBlock(),e.createElementBlock("div",tn,[t[113]||(t[113]=e.createElementVNode("div",{class:"drill-checklist-title"},[e.createElementVNode("i",{class:"bi bi-clipboard2-check me-1"}),e.createTextVNode(" Comments Checklist "),e.createElementVNode("span",{class:"checklist-hint"},"Tick = YES · unticked = NO in the PDF")],-1)),e.createElementVNode("div",on,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.drillChecklistQuestions,(n,a)=>(e.openBlock(),e.createElementBlock("label",{key:a,class:e.normalizeClass(["checklist-item",{checked:i.reportForm.drillChecklist[a]}])},[e.createElementVNode("div",nn,[e.createElementVNode("input",{type:"checkbox",checked:i.reportForm.drillChecklist[a],onChange:c=>i.reportForm.drillChecklist[a]=c.target.checked},null,40,sn),e.createElementVNode("span",ln,[e.createElementVNode("i",{class:e.normalizeClass(["bi",i.reportForm.drillChecklist[a]?"bi-check-lg":"bi-x-lg"])},null,2)])]),e.createElementVNode("span",rn,e.toDisplayString(n),1),e.createElementVNode("span",{class:e.normalizeClass(["checklist-answer",i.reportForm.drillChecklist[a]?"answer-yes":"answer-no"])},e.toDisplayString(i.reportForm.drillChecklist[a]?"YES":"NO"),3)],2))),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",an,[e.createElementVNode("div",dn,[t[114]||(t[114]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Report Title *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[25]||(t[25]=n=>i.reportForm.title=n),placeholder:i.reportForm.entity_ref?`Report — ${i.reportForm.entity_ref}`:"Enter report title"},null,8,cn),[[e.vModelText,i.reportForm.title]])]),e.createElementVNode("div",mn,[t[115]||(t[115]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Submitted By *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[26]||(t[26]=n=>i.reportForm.submittedBy=n),placeholder:"Your name"},null,512),[[e.vModelText,i.reportForm.submittedBy]])])]),e.createElementVNode("div",pn,[e.createElementVNode("div",fn,[t[116]||(t[116]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Date",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",class:"form-control","onUpdate:modelValue":t[27]||(t[27]=n=>i.reportForm.date=n)},null,512),[[e.vModelText,i.reportForm.date]])])]),e.createElementVNode("div",hn,[e.createElementVNode("label",gn,[e.createTextVNode(e.toDisplayString(i.reportForm.entity_type==="incident"?"Description of Event (Findings) *":"Findings / Summary *")+" ",1),i.reportForm.entity_type==="incident"?(e.openBlock(),e.createElementBlock("span",yn,"Pre-filled from incident objective — edit as needed")):e.createCommentVNode("",!0)]),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"4","onUpdate:modelValue":t[28]||(t[28]=n=>i.reportForm.findings=n),placeholder:i.reportForm.entity_type==="drill"?`CREW: John Smith (Master), Jane Doe (Chief Officer), …
7
+ (e.g. lack of training, personal factors, job factors, control management factors, instructions not clear etc.)`,o.inc_root_cause||null,18),y("Action Taken on Board to Avoid Re-occurrence",o.correctiveActions||null,18),y("Any Other Remarks",o.inc_remarks||null,16);for(const p of t)try{let h;if(p.file instanceof File?h=await this._fileToDataUrl(p.file):p.publicUrl&&(h=await this._fetchImageAsDataUrl(p.publicUrl)),!h)continue;c(30),l.setFillColor(235,240,250),l.rect(i,a,s,7,"F"),l.setFontSize(8),l.setFont("helvetica","bold"),l.setTextColor(26,54,107),l.text("ATTACHMENT: "+p.name,i+3,a+5),a+=10;const b=l.getImageProperties(h),k=Math.min(s/b.width,80/b.height),d=b.width*k,m=b.height*k;c(m+5),l.addImage(h,((C=(_=p.type)==null?void 0:_.split("/")[1])==null?void 0:C.toUpperCase())||"JPEG",i,a,d,m),a+=m+8}catch(h){console.warn("Could not embed image",p.name,h)}c(14),a+=4,l.setFontSize(8.5),l.setFont("helvetica","italic"),l.setTextColor(100,110,130),l.text("Closed out on board / Office support required (delete as applicable)",i,a),a+=8;const D=l.getNumberOfPages();for(let p=1;p<=D;p++)l.setPage(p),l.setFillColor(26,54,107),l.rect(0,287,n,10,"F"),l.setTextColor(180,200,240),l.setFontSize(7.5),l.setFont("helvetica","normal"),l.text(`Incident Report · Generated ${new Date().toLocaleDateString("en-GB")} · Page ${p} of ${D}`,i,293),o.entityRef&&l.text(o.entityRef,n-i,293,{align:"right"});return l.output("arraybuffer")},async _buildManualPdf(o,t=[]){var _,C;const{jsPDF:r}=window.jspdf,l=new r({orientation:"portrait",unit:"mm",format:"a4"}),n=18,i=210,s=i-n*2;let a=0;l.setFillColor(30,60,114),l.rect(0,0,i,28,"F"),l.setTextColor(255,255,255),l.setFontSize(16),l.setFont("helvetica","bold"),l.text("QHSE REPORT",n,11),l.setFontSize(9),l.setFont("helvetica","normal"),l.text(this.reportTypeLabel(o),n,18),o.entityRef&&(l.setFontSize(10),l.setFont("helvetica","bold"),l.text(o.entityRef,i-n,18,{align:"right"})),a=36,l.setTextColor(30,60,114),l.setFontSize(13),l.setFont("helvetica","bold");const c=l.splitTextToSize(o.title,s);l.text(c,n,a),a+=c.length*6+4,l.setDrawColor(200,210,230),l.line(n,a,i-n,a),a+=6;const y=[["Submitted By",o.submittedBy||"—"],["Date",o.date||"—"],["Vessel / Location",o.vessel||"—"],["Submitted At",this.formatDate(o.submittedAt)]];o.manualCategory&&y.splice(2,0,["Category",o.manualCategory]);const w=s/2;y.forEach((p,h)=>{const b=h%2,k=Math.floor(h/2),d=n+b*w,m=a+k*10;l.setFontSize(9),l.setFont("helvetica","bold"),l.setTextColor(100,120,160),l.text(p[0].toUpperCase(),d,m),l.setFont("helvetica","normal"),l.setTextColor(40,40,40),l.text(String(p[1]),d,m+4.5)}),a+=Math.ceil(y.length/2)*10+6;const N=(p,h)=>{h&&(a>250&&(l.addPage(),a=20),l.setFillColor(240,245,255),l.roundedRect(n,a,s,7,1,1,"F"),l.setFont("helvetica","bold"),l.setFontSize(9),l.setTextColor(30,60,114),l.text(p.toUpperCase(),n+3,a+5),a+=10,l.setFont("helvetica","normal"),l.setFontSize(10),l.setTextColor(40,40,40),l.splitTextToSize(h,s).forEach(b=>{a>272&&(l.addPage(),a=20),l.text(b,n,a),a+=5.5}),a+=4)};N("Findings / Summary",o.findings),N("Corrective Actions",o.correctiveActions);for(const p of t)try{let h;if(p.file instanceof File?h=await this._fileToDataUrl(p.file):p.publicUrl&&(h=await this._fetchImageAsDataUrl(p.publicUrl)),!h)continue;a>220&&(l.addPage(),a=20),l.setFillColor(240,245,255),l.roundedRect(n,a,s,7,1,1,"F"),l.setFont("helvetica","bold"),l.setFontSize(9),l.setTextColor(30,60,114),l.text("ATTACHMENT: "+p.name,n+3,a+5),a+=10;const b=l.getImageProperties(h),k=Math.min(s/b.width,80/b.height),d=b.width*k,m=b.height*k;a+m>272&&(l.addPage(),a=20),l.addImage(h,((C=(_=p.type)==null?void 0:_.split("/")[1])==null?void 0:C.toUpperCase())||"JPEG",n,a,d,m),a+=m+8}catch(h){console.warn("Could not embed image",p.name,h)}const D=l.getNumberOfPages();for(let p=1;p<=D;p++)l.setPage(p),l.setFillColor(30,60,114),l.rect(0,287,i,10,"F"),l.setTextColor(180,200,240),l.setFontSize(8),l.setFont("helvetica","normal"),l.text(`Generated ${new Date().toLocaleDateString("en-GB")} · Page ${p} of ${D}`,n,293),o.entityRef&&l.text(o.entityRef,i-n,293,{align:"right"});return l.output("arraybuffer")},async _buildAndDownloadZip(o,t,r){const l=new window.JSZip,n=this.safeRef(o),i=l.folder(n);i.file(`${n}_report.pdf`,t);for(const a of r)try{let c;if(a.file instanceof File)c=await a.file.arrayBuffer();else if(a.publicUrl){const y=await fetch(a.publicUrl);if(!y.ok)throw new Error(`HTTP ${y.status}`);c=await y.arrayBuffer()}c&&i.file(a.name,c)}catch(c){console.warn(`Could not add ${a.name} to ZIP:`,c)}const s=await l.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:6}});this._triggerDownload(s,`${n}.zip`)},_triggerDownload(o,t){const r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(r),5e3)},_fileToDataUrl(o){return new Promise((t,r)=>{const l=new FileReader;l.onload=()=>t(l.result),l.onerror=r,l.readAsDataURL(o)})},async _fetchImageAsDataUrl(o){try{const t=await fetch(o);return this._fileToDataUrl(await t.blob())}catch{return null}},handleReportFileAttach(o){this.reportForm.files.push(...Array.from(o.target.files)),o.target.value=""},handleReportFileDrop(o){this.reportForm.files.push(...Array.from(o.dataTransfer.files))},removeReportFile(o){this.reportForm.files.splice(o,1)},requestCreateFolder(){this.newFolderName.trim()&&(this.$emit("folder-create-requested",this.newFolderName.trim()),this.newFolderName="",this.showNewFolderModal=!1,this.activeTab="folders")},selectFolder(o){this.selectedFolder=o,this.$refs.fileInput.click()},handleFileSelection(o){const t=Array.from(o.target.files);!this.selectedFolder||t.length===0||(this.$emit("files-add-requested",{folderId:this.selectedFolder.id,files:t.map(r=>({id:Date.now()+Math.random(),name:r.name,size:r.size,type:r.type,file:r,addedAt:new Date}))}),o.target.value="",this.selectedFolder=null)},toggleFolder(o){const t=this.expandedFolders.indexOf(o);t>-1?this.expandedFolders.splice(t,1):this.expandedFolders.push(o)},formatFileSize(o){if(!o)return"0 B";const t=1024,r=["B","KB","MB","GB"],l=Math.floor(Math.log(o)/Math.log(t));return Math.round(o/Math.pow(t,l)*100)/100+" "+r[l]},formatDate(o){return o?new Date(o).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}}},Oe={class:"reports-container"},Ue={key:0,class:"missing-banner"},je={class:"missing-banner-inner"},Ge={class:"missing-content"},He={key:0},We={class:"ref-chip"},Qe={key:1},Je={key:2},Ye={class:"page-header d-flex justify-content-between align-items-center"},Ze={class:"header-actions"},Ke={class:"btn-group-split"},$e={class:"tab-nav"},Xe={class:"tab-count"},ve={class:"tab-count drill"},et={class:"tab-count incident"},tt={class:"tab-count manual"},ot={class:"tab-count"},st={key:0,class:"loading-container"},nt={key:1},it={key:0,class:"report-cards"},lt=["onClick"],rt={class:"rc-ref"},at={class:"rc-title"},dt={class:"rc-meta"},ct={key:0,class:"rc-files"},mt=["onClick"],pt={class:"rc-actions"},ft=["onClick"],ht=["onClick","disabled"],gt={key:0,class:"spinner-xs"},yt={key:1,class:"bi bi-file-zip"},Et={key:1,class:"empty-state text-center"},Nt={class:"mt-3 text-muted"},bt={class:"text-muted"},Vt={key:0},kt={key:1},wt={key:2},Ct={key:3},Dt={key:2},_t={key:0},ut={class:"section-heading"},St={class:"section-count"},Ft={class:"folders-list"},Bt=["onClick"],xt={class:"af-icon-wrap"},Tt={class:"af-count-badge"},Rt={class:"af-meta"},At={class:"af-ref"},Pt={class:"af-title"},Mt={class:"af-sub"},It={class:"text-muted"},Lt={key:0,class:"text-muted"},qt={class:"af-actions"},zt=["onClick","disabled"],Ot={key:0,class:"spinner-xs"},Ut={key:1,class:"bi bi-file-zip"},jt={key:0,class:"af-contents"},Gt=["onClick"],Ht={class:"ffi-meta"},Wt={class:"ffi-name"},Qt={class:"ffi-acts"},Jt=["onClick"],Yt=["onClick","disabled"],Zt={key:0,class:"spinner-xs"},Kt={key:1,class:"bi bi-download"},$t={class:"ffi-meta"},Xt={class:"ffi-name"},vt={class:"ffi-sub"},eo={class:"ffi-acts"},to=["href"],oo={key:0,class:"ffi-empty"},so={class:"af-zip-row"},no=["onClick","disabled"],io={key:0},lo={key:1},ro={class:"af-zip-hint"},ao={class:"section-heading"},co={class:"section-count"},mo={class:"folders-list"},po=["onClick"],fo={class:"af-icon-wrap"},ho={class:"af-count-badge",style:{background:"#f0ad4e",color:"#664d03"}},go={class:"af-meta"},yo={class:"af-ref"},Eo={class:"af-sub"},No={class:"text-muted"},bo={class:"af-actions"},Vo=["onClick"],ko=["onClick"],wo={key:0,class:"af-contents"},Co={class:"ffi-meta"},Do={class:"ffi-name"},_o={class:"ffi-sub"},uo={class:"ffi-acts"},So=["onClick"],Fo={key:0,class:"ffi-empty"},Bo=["onClick"],xo={key:2,class:"empty-state text-center"},To={class:"modal-dialog modal-dialog-centered"},Ro={class:"modal-content"},Ao={class:"modal-header"},Po={class:"modal-body"},Mo={class:"modal-footer"},Io=["disabled"],Lo={class:"modal-dialog modal-dialog-centered modal-lg"},qo={class:"modal-content"},zo={class:"modal-header rpt-modal-header"},Oo={class:"modal-title"},Uo={key:0,class:"modal-type-toggle"},jo={class:"modal-body"},Go={key:0,class:"rpt-entity-box"},Ho={key:0,class:"prefilled-entity"},Wo={class:"text-muted ms-2"},Qo={key:1},Jo={label:"Missing Drill Reports"},Yo=["value"],Zo={label:"Missing Incident Reports"},Ko=["value"],$o={key:1,class:"input-row"},Xo={class:"form-group"},vo={class:"form-group"},es={key:2,class:"crew-hint"},ts={key:3,class:"drill-checklist-box"},os={class:"checklist-grid"},ss={class:"checklist-checkbox"},ns=["checked","onChange"],is={class:"custom-check"},ls={class:"checklist-q"},rs={class:"input-row mt-3"},as={class:"form-group"},ds=["placeholder"],cs={class:"form-group"},ms={class:"input-row"},ps={class:"form-group"},fs={class:"form-group"},hs={class:"form-label fw-semibold"},gs={key:0,class:"form-hint"},ys=["placeholder"],Es={key:4,class:"incident-fields-box"},Ns={class:"form-group"},bs={class:"form-group"},Vs={class:"form-group"},ks={class:"input-row",style:{"margin-bottom":"0"}},ws={class:"form-group"},Cs={class:"form-group"},Ds={class:"form-group"},_s={class:"form-group",style:{"margin-bottom":"0"}},us={key:5,class:"form-group"},Ss={class:"form-group"},Fs={key:0,class:"attached-files"},Bs=["onClick"],xs={key:6,class:"zip-hint"},Ts={key:0},Rs={class:"modal-footer"},As=["disabled"],Ps={key:0},Ms={key:1},Is={class:"modal-dialog modal-dialog-centered modal-lg"},Ls={key:0,class:"modal-content"},qs={class:"modal-header rpt-modal-header"},zs={class:"d-flex align-items-center gap-2"},Os={style:{color:"#fff"}},Us={class:"modal-body"},js={class:"view-grid"},Gs={class:"view-item"},Hs={class:"ref-mono"},Ws={class:"view-item"},Qs={key:0,class:"view-item"},Js={class:"view-item"},Ys={class:"view-item"},Zs={key:1,class:"view-item"},Ks={class:"view-item"},$s={key:2,class:"view-item"},Xs={key:3,class:"view-item"},vs={key:4,class:"view-item"},en={key:5,class:"view-item"},tn={class:"view-section"},on={class:"view-text"},sn={key:0,class:"view-section"},nn={class:"view-text"},ln={key:1,class:"view-section"},rn={class:"attached-files mt-1"},an=["href"],dn={class:"text-muted ms-1"},cn={class:"modal-footer"},mn=["disabled"],pn={key:0},fn={key:1};function hn(o,t,r,l,n,i){return e.openBlock(),e.createElementBlock("div",Oe,[e.createVNode(e.Transition,{name:"slide-down"},{default:e.withCtx(()=>[!n.bannerDismissed&&(r.pendingContext||r.missingReports.length>0)?(e.openBlock(),e.createElementBlock("div",Ue,[e.createElementVNode("div",je,[t[54]||(t[54]=e.createElementVNode("div",{class:"missing-icon"},[e.createElementVNode("i",{class:"bi bi-exclamation-triangle-fill"})],-1)),e.createElementVNode("div",Ge,[r.pendingContext?(e.openBlock(),e.createElementBlock("strong",He,[t[50]||(t[50]=e.createTextVNode(" Action Required — Report for ",-1)),e.createElementVNode("span",We,e.toDisplayString(r.pendingContext.entity_ref),1),t[51]||(t[51]=e.createTextVNode(" must be submitted ",-1))])):(e.openBlock(),e.createElementBlock("strong",Qe,e.toDisplayString(r.missingReports.length)+" report"+e.toDisplayString(r.missingReports.length>1?"s":"")+" awaiting submission ",1)),r.pendingContext?(e.openBlock(),e.createElementBlock("p",Je,e.toDisplayString(r.pendingContext.title),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{class:"btn btn-warning btn-sm fw-bold",onClick:t[0]||(t[0]=s=>i.openReportForm("qhse"))},t[52]||(t[52]=[e.createElementVNode("i",{class:"bi bi-pencil-square me-1"},null,-1),e.createTextVNode(" Submit Report ",-1)])),e.createElementVNode("button",{class:"btn-dismiss",onClick:t[1]||(t[1]=(...s)=>i.dismissBanner&&i.dismissBanner(...s)),title:"Dismiss"},t[53]||(t[53]=[e.createElementVNode("i",{class:"bi bi-x-lg"},null,-1)]))])])):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("div",Ye,[t[58]||(t[58]=e.createElementVNode("div",null,[e.createElementVNode("h4",{class:"page-title"},"Reports"),e.createElementVNode("p",{class:"page-subtitle"},"Document Management & QHSE Reports")],-1)),e.createElementVNode("div",Ze,[e.createElementVNode("div",Ke,[e.createElementVNode("button",{class:"btn btn-outline-primary",onClick:t[2]||(t[2]=s=>i.openReportForm("qhse"))},t[55]||(t[55]=[e.createElementVNode("i",{class:"bi bi-shield-check"},null,-1),e.createTextVNode(" QHSE Report ",-1)])),e.createElementVNode("button",{class:"btn btn-outline-secondary",onClick:t[3]||(t[3]=s=>i.openReportForm("manual"))},t[56]||(t[56]=[e.createElementVNode("i",{class:"bi bi-file-earmark-plus"},null,-1),e.createTextVNode(" Manual Report ",-1)])),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[4]||(t[4]=s=>n.showNewFolderModal=!0)},t[57]||(t[57]=[e.createElementVNode("i",{class:"bi bi-folder-plus"},null,-1),e.createTextVNode(" New Folder ",-1)]))])])]),e.createElementVNode("div",$e,[e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:n.activeTab==="all"}]),onClick:t[5]||(t[5]=s=>n.activeTab="all")},[t[59]||(t[59]=e.createTextVNode(" All Reports ",-1)),e.createElementVNode("span",Xe,e.toDisplayString(r.reports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:n.activeTab==="drill"}]),onClick:t[6]||(t[6]=s=>n.activeTab="drill")},[t[60]||(t[60]=e.createElementVNode("i",{class:"bi bi-people-fill me-1"},null,-1)),t[61]||(t[61]=e.createTextVNode("Drills ",-1)),e.createElementVNode("span",ve,e.toDisplayString(i.drillReports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:n.activeTab==="incident"}]),onClick:t[7]||(t[7]=s=>n.activeTab="incident")},[t[62]||(t[62]=e.createElementVNode("i",{class:"bi bi-exclamation-octagon-fill me-1"},null,-1)),t[63]||(t[63]=e.createTextVNode("Incidents ",-1)),e.createElementVNode("span",et,e.toDisplayString(i.incidentReports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:n.activeTab==="manual"}]),onClick:t[8]||(t[8]=s=>n.activeTab="manual")},[t[64]||(t[64]=e.createElementVNode("i",{class:"bi bi-file-earmark-text me-1"},null,-1)),t[65]||(t[65]=e.createTextVNode("Manual ",-1)),e.createElementVNode("span",tt,e.toDisplayString(i.manualReports.length),1)],2),e.createElementVNode("button",{class:e.normalizeClass(["tab-btn",{active:n.activeTab==="folders"}]),onClick:t[9]||(t[9]=s=>n.activeTab="folders")},[t[66]||(t[66]=e.createElementVNode("i",{class:"bi bi-folder-fill me-1"},null,-1)),t[67]||(t[67]=e.createTextVNode("Folders ",-1)),e.createElementVNode("span",ot,e.toDisplayString(r.reports.length+r.folders.length),1)],2)]),r.isLoading?(e.openBlock(),e.createElementBlock("div",st,t[68]||(t[68]=[e.createElementVNode("div",{class:"spinner"},null,-1),e.createElementVNode("p",null,"Loading reports…",-1)]))):e.createCommentVNode("",!0),n.activeTab!=="folders"&&!r.isLoading?(e.openBlock(),e.createElementBlock("div",nt,[i.filteredReports.length>0?(e.openBlock(),e.createElementBlock("div",it,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.filteredReports,s=>{var a;return e.openBlock(),e.createElementBlock("div",{key:s.id,ref_for:!0,ref:"report-"+s.entityRef,class:e.normalizeClass(["report-card",{"report-card--highlighted":n.highlightedRef===s.entityRef}])},[e.createElementVNode("div",{class:e.normalizeClass(["rc-type-bar",i.reportTypeClass(s)])},null,2),e.createElementVNode("div",{class:e.normalizeClass(["rc-badge",i.reportTypeClass(s)])},e.toDisplayString(i.reportTypeLabel(s)),3),e.createElementVNode("div",{class:"rc-body",onClick:c=>i.viewReport(s)},[e.createElementVNode("strong",rt,e.toDisplayString(s.entityRef||((a=s.id)==null?void 0:a.slice(0,8).toUpperCase())),1),e.createElementVNode("span",at,e.toDisplayString(s.title),1),e.createElementVNode("span",dt,[t[69]||(t[69]=e.createElementVNode("i",{class:"bi bi-person-fill me-1"},null,-1)),e.createTextVNode(e.toDisplayString(s.submittedBy)+"  ·  ",1),t[70]||(t[70]=e.createElementVNode("i",{class:"bi bi-calendar3 me-1"},null,-1)),e.createTextVNode(e.toDisplayString(i.formatDate(s.submittedAt)),1)])],8,lt),i.getFilesForReport(s.id).length>0?(e.openBlock(),e.createElementBlock("div",ct,[t[71]||(t[71]=e.createElementVNode("i",{class:"bi bi-paperclip"},null,-1)),e.createTextVNode(" "+e.toDisplayString(i.getFilesForReport(s.id).length),1)])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:e.normalizeClass(["rc-folder-pill",i.reportTypeClass(s)]),onClick:e.withModifiers(c=>i.jumpToFolder(s),["stop"]),title:"View folder"},[t[72]||(t[72]=e.createElementVNode("i",{class:"bi bi-folder-fill me-1"},null,-1)),e.createTextVNode(" "+e.toDisplayString(s.entityRef||s.title),1)],10,mt),e.createElementVNode("div",pt,[e.createElementVNode("button",{class:"rc-btn rc-btn--view",onClick:c=>i.viewReport(s),title:"View"},t[73]||(t[73]=[e.createElementVNode("i",{class:"bi bi-eye"},null,-1)]),8,ft),e.createElementVNode("button",{class:"rc-btn rc-btn--download",onClick:c=>i.downloadReport(s),disabled:n.generatingPdf===s.id,title:"Download ZIP"},[n.generatingPdf===s.id?(e.openBlock(),e.createElementBlock("span",gt)):(e.openBlock(),e.createElementBlock("i",yt))],8,ht)])],2)}),128))])):e.createCommentVNode("",!0),i.filteredReports.length===0?(e.openBlock(),e.createElementBlock("div",Et,[t[74]||(t[74]=e.createElementVNode("i",{class:"bi bi-file-earmark-x",style:{"font-size":"3.5rem",color:"#ccc"}},null,-1)),e.createElementVNode("h5",Nt,"No "+e.toDisplayString(n.activeTab==="all"?"":n.activeTab)+" reports yet",1),e.createElementVNode("p",bt,[n.activeTab==="manual"?(e.openBlock(),e.createElementBlock("span",Vt,"Create a manual report using the button above")):n.activeTab==="drill"?(e.openBlock(),e.createElementBlock("span",kt,"Submit a report after logging a drill")):n.activeTab==="incident"?(e.openBlock(),e.createElementBlock("span",wt,"Submit a report after logging an incident")):(e.openBlock(),e.createElementBlock("span",Ct,"Submit a report or create a folder to get started"))])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),n.activeTab==="folders"&&!r.isLoading?(e.openBlock(),e.createElementBlock("div",Dt,[r.reports.length>0?(e.openBlock(),e.createElementBlock("div",_t,[e.createElementVNode("div",ut,[t[75]||(t[75]=e.createElementVNode("i",{class:"bi bi-folder-symlink-fill text-primary me-1"},null,-1)),t[76]||(t[76]=e.createTextVNode(" Report Folders ",-1)),e.createElementVNode("span",St,e.toDisplayString(r.reports.length),1),t[77]||(t[77]=e.createElementVNode("span",{class:"section-hint"},"Auto-generated · one per submitted report",-1))]),e.createElementVNode("div",Ft,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.reports,s=>{var a;return e.openBlock(),e.createElementBlock("div",{key:"af-"+s.id,ref_for:!0,ref:"folder-"+(s.entityRef||s.id),class:e.normalizeClass(["auto-folder-card",i.reportTypeClass(s),{"is-open":n.expandedFolders.includes("auto-"+s.id)}])},[e.createElementVNode("div",{class:"af-header",onClick:c=>i.toggleFolder("auto-"+s.id)},[e.createElementVNode("div",xt,[e.createElementVNode("i",{class:e.normalizeClass(["bi bi-folder-fill af-folder-icon","color--"+i.reportTypeClass(s)])},null,2),e.createElementVNode("span",Tt,e.toDisplayString(1+i.getFilesForReport(s.id).length),1)]),e.createElementVNode("div",Rt,[e.createElementVNode("span",At,e.toDisplayString(s.entityRef||((a=s.id)==null?void 0:a.slice(0,8).toUpperCase())),1),e.createElementVNode("span",Pt,e.toDisplayString(s.title),1),e.createElementVNode("div",Mt,[e.createElementVNode("span",{class:e.normalizeClass(["mini-badge",i.reportTypeClass(s)])},e.toDisplayString(i.reportTypeLabel(s)),3),e.createElementVNode("span",It,e.toDisplayString(i.formatDate(s.submittedAt)),1),i.getFilesForReport(s.id).length?(e.openBlock(),e.createElementBlock("span",Lt," · "+e.toDisplayString(i.getFilesForReport(s.id).length)+" attachment"+e.toDisplayString(i.getFilesForReport(s.id).length!==1?"s":""),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",qt,[e.createElementVNode("button",{class:"rc-btn rc-btn--download",onClick:e.withModifiers(c=>i.downloadReport(s),["stop"]),disabled:n.generatingPdf===s.id,title:"Download ZIP"},[n.generatingPdf===s.id?(e.openBlock(),e.createElementBlock("span",Ot)):(e.openBlock(),e.createElementBlock("i",Ut))],8,zt),e.createElementVNode("i",{class:e.normalizeClass(["bi chevron-icon",n.expandedFolders.includes("auto-"+s.id)?"bi-chevron-up":"bi-chevron-down"])},null,2)])],8,Bt),e.createVNode(e.Transition,{name:"folder-expand"},{default:e.withCtx(()=>[n.expandedFolders.includes("auto-"+s.id)?(e.openBlock(),e.createElementBlock("div",jt,[e.createElementVNode("div",{class:"ffi ffi--report",onClick:c=>i.viewReport(s)},[t[80]||(t[80]=e.createElementVNode("div",{class:"ffi-icon ffi-icon--pdf"},[e.createElementVNode("i",{class:"bi bi-file-earmark-pdf-fill"})],-1)),e.createElementVNode("div",Ht,[e.createElementVNode("span",Wt,e.toDisplayString(i.safeRef(s))+"_report.pdf",1),t[78]||(t[78]=e.createElementVNode("span",{class:"ffi-sub"},"Generated report sheet · click to preview",-1))]),e.createElementVNode("div",Qt,[e.createElementVNode("button",{class:"rc-btn rc-btn--view",onClick:e.withModifiers(c=>i.viewReport(s),["stop"]),title:"Preview"},t[79]||(t[79]=[e.createElementVNode("i",{class:"bi bi-eye"},null,-1)]),8,Jt),e.createElementVNode("button",{class:"rc-btn rc-btn--download",onClick:e.withModifiers(c=>i.downloadReportPdfOnly(s),["stop"]),disabled:n.generatingPdf===s.id+"-pdf",title:"Download PDF only"},[n.generatingPdf===s.id+"-pdf"?(e.openBlock(),e.createElementBlock("span",Zt)):(e.openBlock(),e.createElementBlock("i",Kt))],8,Yt)])],8,Gt),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.getFilesForReport(s.id),c=>(e.openBlock(),e.createElementBlock("div",{key:c.id,class:"ffi"},[e.createElementVNode("div",{class:e.normalizeClass(["ffi-icon",i.ffiIconClass(c)])},[e.createElementVNode("i",{class:e.normalizeClass(["bi",i.fileIcon(c.type)])},null,2)],2),e.createElementVNode("div",$t,[e.createElementVNode("span",Xt,e.toDisplayString(c.name),1),e.createElementVNode("span",vt,e.toDisplayString(i.formatFileSize(c.size)),1)]),e.createElementVNode("div",eo,[c.publicUrl?(e.openBlock(),e.createElementBlock("a",{key:0,href:c.publicUrl,target:"_blank",rel:"noopener",class:"rc-btn rc-btn--view",title:"Open"},t[81]||(t[81]=[e.createElementVNode("i",{class:"bi bi-box-arrow-up-right"},null,-1)]),8,to)):e.createCommentVNode("",!0)])]))),128)),i.getFilesForReport(s.id).length===0?(e.openBlock(),e.createElementBlock("div",oo,t[82]||(t[82]=[e.createElementVNode("i",{class:"bi bi-paperclip me-1"},null,-1),e.createTextVNode("No attachments — ZIP will contain the report PDF only ",-1)]))):e.createCommentVNode("",!0),e.createElementVNode("div",so,[e.createElementVNode("button",{class:"btn btn-sm btn-outline-primary",onClick:c=>i.downloadReport(s),disabled:n.generatingPdf===s.id},[n.generatingPdf===s.id?(e.openBlock(),e.createElementBlock("span",io,t[83]||(t[83]=[e.createElementVNode("span",{class:"spinner-xs me-1"},null,-1),e.createTextVNode("Building ZIP… ",-1)]))):(e.openBlock(),e.createElementBlock("span",lo,t[84]||(t[84]=[e.createElementVNode("i",{class:"bi bi-file-zip me-1"},null,-1),e.createTextVNode("Download all as ZIP ",-1)])))],8,no),e.createElementVNode("span",ro,e.toDisplayString(i.safeRef(s))+".zip · report PDF"+e.toDisplayString(i.getFilesForReport(s.id).length?" + "+i.getFilesForReport(s.id).length+" file(s)":""),1)])])):e.createCommentVNode("",!0)]),_:2},1024)],2)}),128))])])):e.createCommentVNode("",!0),r.folders.length>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass({"mt-4":r.reports.length>0})},[e.createElementVNode("div",ao,[t[85]||(t[85]=e.createElementVNode("i",{class:"bi bi-folder-plus text-warning me-1"},null,-1)),t[86]||(t[86]=e.createTextVNode(" Custom Folders ",-1)),e.createElementVNode("span",co,e.toDisplayString(r.folders.length),1)]),e.createElementVNode("div",mo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.folders,s=>(e.openBlock(),e.createElementBlock("div",{key:"uf-"+s.id,class:e.normalizeClass(["user-folder-card",{"is-open":n.expandedFolders.includes("user-"+s.id)}])},[e.createElementVNode("div",{class:"af-header",onClick:a=>i.toggleFolder("user-"+s.id)},[e.createElementVNode("div",fo,[t[87]||(t[87]=e.createElementVNode("i",{class:"bi bi-folder-fill af-folder-icon color--user"},null,-1)),e.createElementVNode("span",ho,e.toDisplayString(s.files.length),1)]),e.createElementVNode("div",go,[e.createElementVNode("span",yo,e.toDisplayString(s.name),1),e.createElementVNode("span",Eo,[e.createElementVNode("span",No,e.toDisplayString(s.files.length)+" file"+e.toDisplayString(s.files.length!==1?"s":""),1)])]),e.createElementVNode("div",bo,[e.createElementVNode("button",{class:"rc-btn",style:{color:"#6f42c1"},onClick:e.withModifiers(a=>i.selectFolder(s),["stop"]),title:"Add Files"},t[88]||(t[88]=[e.createElementVNode("i",{class:"bi bi-file-earmark-plus"},null,-1)]),8,Vo),e.createElementVNode("button",{class:"rc-btn rc-btn--danger",onClick:e.withModifiers(a=>o.$emit("folder-delete-requested",s.id),["stop"]),title:"Delete"},t[89]||(t[89]=[e.createElementVNode("i",{class:"bi bi-trash"},null,-1)]),8,ko),e.createElementVNode("i",{class:e.normalizeClass(["bi chevron-icon",n.expandedFolders.includes("user-"+s.id)?"bi-chevron-up":"bi-chevron-down"])},null,2)])],8,po),e.createVNode(e.Transition,{name:"folder-expand"},{default:e.withCtx(()=>[n.expandedFolders.includes("user-"+s.id)?(e.openBlock(),e.createElementBlock("div",wo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.files,a=>(e.openBlock(),e.createElementBlock("div",{key:a.id,class:"ffi"},[e.createElementVNode("div",{class:e.normalizeClass(["ffi-icon",i.ffiIconClass(a)])},[e.createElementVNode("i",{class:e.normalizeClass(["bi",i.fileIcon(a.type)])},null,2)],2),e.createElementVNode("div",Co,[e.createElementVNode("span",Do,e.toDisplayString(a.name),1),e.createElementVNode("span",_o,e.toDisplayString(i.formatFileSize(a.size)),1)]),e.createElementVNode("div",uo,[e.createElementVNode("button",{class:"rc-btn rc-btn--danger",onClick:c=>o.$emit("file-remove-requested",{folderId:s.id,fileId:a.id}),title:"Remove"},t[90]||(t[90]=[e.createElementVNode("i",{class:"bi bi-x-circle"},null,-1)]),8,So)])]))),128)),s.files.length===0?(e.openBlock(),e.createElementBlock("div",Fo,[t[92]||(t[92]=e.createElementVNode("i",{class:"bi bi-inbox me-1"},null,-1)),t[93]||(t[93]=e.createTextVNode("Empty folder ",-1)),e.createElementVNode("button",{class:"btn btn-sm btn-outline-secondary ms-2",onClick:a=>i.selectFolder(s)},t[91]||(t[91]=[e.createElementVNode("i",{class:"bi bi-file-earmark-plus me-1"},null,-1),e.createTextVNode("Add Files ",-1)]),8,Bo)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),_:2},1024)],2))),128))])],2)):e.createCommentVNode("",!0),r.reports.length===0&&r.folders.length===0?(e.openBlock(),e.createElementBlock("div",xo,[t[95]||(t[95]=e.createElementVNode("i",{class:"bi bi-folder2-open",style:{"font-size":"3.5rem",color:"#ccc"}},null,-1)),t[96]||(t[96]=e.createElementVNode("h5",{class:"mt-3 text-muted"},"No folders yet",-1)),t[97]||(t[97]=e.createElementVNode("p",{class:"text-muted"},"Each submitted report auto-creates a folder here. You can also create custom folders.",-1)),e.createElementVNode("button",{class:"btn btn-primary mt-2",onClick:t[10]||(t[10]=s=>n.showNewFolderModal=!0)},t[94]||(t[94]=[e.createElementVNode("i",{class:"bi bi-folder-plus me-1"},null,-1),e.createTextVNode(" New Folder ",-1)]))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["modal",{show:n.showNewFolderModal}]),onClick:t[16]||(t[16]=e.withModifiers(s=>n.showNewFolderModal=!1,["self"]))},[e.createElementVNode("div",To,[e.createElementVNode("div",Ro,[e.createElementVNode("div",Ao,[t[98]||(t[98]=e.createElementVNode("h5",{class:"modal-title"},[e.createElementVNode("i",{class:"bi bi-folder-plus me-2"}),e.createTextVNode("Create New Folder")],-1)),e.createElementVNode("button",{type:"button",class:"btn-close",onClick:t[11]||(t[11]=s=>n.showNewFolderModal=!1)})]),e.createElementVNode("div",Po,[t[99]||(t[99]=e.createElementVNode("label",{class:"form-label"},"Folder Name",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[12]||(t[12]=s=>n.newFolderName=s),onKeyup:t[13]||(t[13]=e.withKeys((...s)=>i.requestCreateFolder&&i.requestCreateFolder(...s),["enter"])),placeholder:"e.g., Q1 2025 Drills"},null,544),[[e.vModelText,n.newFolderName]])]),e.createElementVNode("div",Mo,[e.createElementVNode("button",{type:"button",class:"btn btn-secondary",onClick:t[14]||(t[14]=s=>n.showNewFolderModal=!1)},"Cancel"),e.createElementVNode("button",{type:"button",class:"btn btn-primary",onClick:t[15]||(t[15]=(...s)=>i.requestCreateFolder&&i.requestCreateFolder(...s)),disabled:!n.newFolderName.trim()},"Create Folder",8,Io)])])])],2),e.createElementVNode("div",{class:e.normalizeClass(["modal",{show:n.showReportModal}]),onClick:t[43]||(t[43]=e.withModifiers((...s)=>i.closeReportForm&&i.closeReportForm(...s),["self"]))},[e.createElementVNode("div",Lo,[e.createElementVNode("div",qo,[e.createElementVNode("div",zo,[e.createElementVNode("h5",Oo,[e.createElementVNode("i",{class:e.normalizeClass(n.reportForm.report_type==="manual"?"bi bi-file-earmark-text me-2":"bi bi-shield-check me-2")},null,2),e.createTextVNode(" "+e.toDisplayString(n.reportForm.report_type==="manual"?"New Manual Report":"Submit QHSE Report"),1)]),r.pendingContext?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Uo,[e.createElementVNode("button",{class:e.normalizeClass(["type-toggle-btn",{active:n.reportForm.report_type==="qhse"}]),onClick:t[17]||(t[17]=s=>n.reportForm.report_type="qhse")},t[100]||(t[100]=[e.createElementVNode("i",{class:"bi bi-shield-check me-1"},null,-1),e.createTextVNode("QHSE ",-1)]),2),e.createElementVNode("button",{class:e.normalizeClass(["type-toggle-btn",{active:n.reportForm.report_type==="manual"}]),onClick:t[18]||(t[18]=s=>n.reportForm.report_type="manual")},t[101]||(t[101]=[e.createElementVNode("i",{class:"bi bi-file-earmark-text me-1"},null,-1),e.createTextVNode("Manual ",-1)]),2)])),e.createElementVNode("button",{type:"button",class:"btn-close btn-close-white",onClick:t[19]||(t[19]=(...s)=>i.closeReportForm&&i.closeReportForm(...s))})]),e.createElementVNode("div",jo,[n.reportForm.report_type==="qhse"?(e.openBlock(),e.createElementBlock("div",Go,[t[105]||(t[105]=e.createElementVNode("label",{class:"form-label fw-semibold"},[e.createElementVNode("i",{class:"bi bi-link-45deg me-1"}),e.createTextVNode("Link to Drill / Incident")],-1)),n.reportForm.entity_ref&&n.reportForm.entity_type?(e.openBlock(),e.createElementBlock("div",Ho,[e.createElementVNode("span",{class:e.normalizeClass(["entity-chip",n.reportForm.entity_type])},e.toDisplayString(n.reportForm.entity_type==="drill"?"DRILL":"INCIDENT"),3),e.createElementVNode("strong",null,e.toDisplayString(n.reportForm.entity_ref),1),e.createElementVNode("span",Wo,e.toDisplayString(n.reportForm.entity_label),1),e.createElementVNode("button",{class:"btn btn-link btn-sm text-danger ms-auto",onClick:t[20]||(t[20]=(...s)=>i.clearEntityLink&&i.clearEntityLink(...s))},t[102]||(t[102]=[e.createElementVNode("i",{class:"bi bi-x-circle"},null,-1),e.createTextVNode(" Clear",-1)]))])):(e.openBlock(),e.createElementBlock("div",Qo,[e.withDirectives(e.createElementVNode("select",{class:"form-control","onUpdate:modelValue":t[21]||(t[21]=s=>n.reportForm.selectedMissing=s),onChange:t[22]||(t[22]=(...s)=>i.applyMissingSelection&&i.applyMissingSelection(...s))},[t[103]||(t[103]=e.createElementVNode("option",{value:""},"— Select a missing report (optional) —",-1)),e.createElementVNode("optgroup",Jo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.missingReports.filter(s=>s.entity_type==="drill"),s=>(e.openBlock(),e.createElementBlock("option",{key:s.entity_id,value:JSON.stringify(s)},e.toDisplayString(s.entity_ref)+" — "+e.toDisplayString(s.label),9,Yo))),128))]),e.createElementVNode("optgroup",Zo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.missingReports.filter(s=>s.entity_type==="incident"),s=>(e.openBlock(),e.createElementBlock("option",{key:s.entity_id,value:JSON.stringify(s)},e.toDisplayString(s.entity_ref)+" — "+e.toDisplayString(s.label),9,Ko))),128))])],544),[[e.vModelSelect,n.reportForm.selectedMissing]]),t[104]||(t[104]=e.createElementVNode("small",{class:"text-muted"},"Linking will mark the drill / incident as reported.",-1))]))])):e.createCommentVNode("",!0),n.reportForm.report_type==="manual"?(e.openBlock(),e.createElementBlock("div",$o,[e.createElementVNode("div",Xo,[t[107]||(t[107]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Report Category",-1)),e.withDirectives(e.createElementVNode("select",{class:"form-control","onUpdate:modelValue":t[23]||(t[23]=s=>n.reportForm.manual_category=s)},t[106]||(t[106]=[e.createElementVNode("option",null,"General",-1),e.createElementVNode("option",null,"Maintenance",-1),e.createElementVNode("option",null,"Safety Observation",-1),e.createElementVNode("option",null,"Environmental",-1),e.createElementVNode("option",null,"Audit",-1),e.createElementVNode("option",null,"Training",-1),e.createElementVNode("option",null,"Other",-1)]),512),[[e.vModelSelect,n.reportForm.manual_category]])]),e.createElementVNode("div",vo,[t[108]||(t[108]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Reference Number",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[24]||(t[24]=s=>n.reportForm.manual_ref=s),placeholder:"e.g. RPT-2025-001"},null,512),[[e.vModelText,n.reportForm.manual_ref]])])])):e.createCommentVNode("",!0),n.reportForm.entity_type==="drill"?(e.openBlock(),e.createElementBlock("div",es,[t[112]||(t[112]=e.createElementVNode("i",{class:"bi bi-info-circle-fill me-1"},null,-1)),e.createElementVNode("span",null,[t[109]||(t[109]=e.createElementVNode("strong",null,"Crew list tip:",-1)),t[110]||(t[110]=e.createTextVNode(" Start your Findings with ",-1)),t[111]||(t[111]=e.createElementVNode("code",null,"CREW: Name (Rank), Name (Rank), …",-1)),e.createTextVNode(" to generate a named crew participation table in the PDF. Otherwise the PDF will show the total count ("+e.toDisplayString(n.reportForm.entity_participants||0)+" members) with a note to attach the signed list. ",1)])])):e.createCommentVNode("",!0),n.reportForm.entity_type==="drill"?(e.openBlock(),e.createElementBlock("div",ts,[t[113]||(t[113]=e.createElementVNode("div",{class:"drill-checklist-title"},[e.createElementVNode("i",{class:"bi bi-clipboard2-check me-1"}),e.createTextVNode(" Comments Checklist "),e.createElementVNode("span",{class:"checklist-hint"},"Tick = YES · unticked = NO in the PDF")],-1)),e.createElementVNode("div",os,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.drillChecklistQuestions,(s,a)=>(e.openBlock(),e.createElementBlock("label",{key:a,class:e.normalizeClass(["checklist-item",{checked:n.reportForm.drillChecklist[a]}])},[e.createElementVNode("div",ss,[e.createElementVNode("input",{type:"checkbox",checked:n.reportForm.drillChecklist[a],onChange:c=>n.reportForm.drillChecklist[a]=c.target.checked},null,40,ns),e.createElementVNode("span",is,[e.createElementVNode("i",{class:e.normalizeClass(["bi",n.reportForm.drillChecklist[a]?"bi-check-lg":"bi-x-lg"])},null,2)])]),e.createElementVNode("span",ls,e.toDisplayString(s),1),e.createElementVNode("span",{class:e.normalizeClass(["checklist-answer",n.reportForm.drillChecklist[a]?"answer-yes":"answer-no"])},e.toDisplayString(n.reportForm.drillChecklist[a]?"YES":"NO"),3)],2))),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",rs,[e.createElementVNode("div",as,[t[114]||(t[114]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Report Title *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[25]||(t[25]=s=>n.reportForm.title=s),placeholder:n.reportForm.entity_ref?`Report — ${n.reportForm.entity_ref}`:"Enter report title"},null,8,ds),[[e.vModelText,n.reportForm.title]])]),e.createElementVNode("div",cs,[t[115]||(t[115]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Submitted By *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",class:"form-control","onUpdate:modelValue":t[26]||(t[26]=s=>n.reportForm.submittedBy=s),placeholder:"Your name"},null,512),[[e.vModelText,n.reportForm.submittedBy]])])]),e.createElementVNode("div",ms,[e.createElementVNode("div",ps,[t[116]||(t[116]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Date",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",class:"form-control","onUpdate:modelValue":t[27]||(t[27]=s=>n.reportForm.date=s)},null,512),[[e.vModelText,n.reportForm.date]])])]),e.createElementVNode("div",fs,[e.createElementVNode("label",hs,[e.createTextVNode(e.toDisplayString(n.reportForm.entity_type==="incident"?"Description of Event (Findings) *":"Findings / Summary *")+" ",1),n.reportForm.entity_type==="incident"?(e.openBlock(),e.createElementBlock("span",gs,"Pre-filled from incident objective — edit as needed")):e.createCommentVNode("",!0)]),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"4","onUpdate:modelValue":t[28]||(t[28]=s=>n.reportForm.findings=s),placeholder:n.reportForm.entity_type==="drill"?`CREW: John Smith (Master), Jane Doe (Chief Officer), …
8
8
 
9
- Then describe the drill scenario and findings…`:i.reportForm.entity_type==="incident"?"Describe what happened, when, and where…":"Describe findings, observations, and outcomes…"}," ",8,En),[[e.vModelText,i.reportForm.findings]])]),i.reportForm.entity_type==="incident"?(e.openBlock(),e.createElementBlock("div",Nn,[t[128]||(t[128]=e.createElementVNode("div",{class:"incident-fields-title"},[e.createElementVNode("i",{class:"bi bi-layout-text-window-reverse me-1"}),e.createTextVNode(" Incident Report Fields "),e.createElementVNode("span",{class:"checklist-hint"},"These map directly to the PDF sections")],-1)),e.createElementVNode("div",bn,[t[117]||(t[117]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Possible Consequences",-1)),t[118]||(t[118]=e.createElementVNode("div",{class:"field-hint"},"e.g. Personal injury, damage, collision, grounding, fire, pollution",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[29]||(t[29]=n=>i.reportForm.inc_consequences=n),placeholder:"Describe possible consequences…"},null,512),[[e.vModelText,i.reportForm.inc_consequences]])]),e.createElementVNode("div",Vn,[t[119]||(t[119]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Relevant Factors / Conditions Surrounding the Event",-1)),t[120]||(t[120]=e.createElementVNode("div",{class:"field-hint"},"e.g. weather, lighting, fatigue, time pressure",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[30]||(t[30]=n=>i.reportForm.inc_factors=n),placeholder:"Describe relevant factors and conditions…"},null,512),[[e.vModelText,i.reportForm.inc_factors]])]),e.createElementVNode("div",kn,[t[121]||(t[121]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Immediate Action Taken",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[31]||(t[31]=n=>i.reportForm.inc_immediate_action=n),placeholder:"What was done immediately after the event?"},null,512),[[e.vModelText,i.reportForm.inc_immediate_action]])]),e.createElementVNode("div",wn,[e.createElementVNode("div",Cn,[t[122]||(t[122]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Direct Cause",-1)),t[123]||(t[123]=e.createElementVNode("div",{class:"field-hint"},"e.g. failure to follow procedures, defective equipment ",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"3","onUpdate:modelValue":t[32]||(t[32]=n=>i.reportForm.inc_direct_cause=n),placeholder:"Direct cause of the event…"},null,512),[[e.vModelText,i.reportForm.inc_direct_cause]])]),e.createElementVNode("div",Dn,[t[124]||(t[124]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Root Cause",-1)),t[125]||(t[125]=e.createElementVNode("div",{class:"field-hint"},"e.g. lack of training, management factors",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"3","onUpdate:modelValue":t[33]||(t[33]=n=>i.reportForm.inc_root_cause=n),placeholder:"Root / underlying cause…"},null,512),[[e.vModelText,i.reportForm.inc_root_cause]])])]),e.createElementVNode("div",_n,[t[126]||(t[126]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Action Taken to Avoid Re-occurrence",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[34]||(t[34]=n=>i.reportForm.correctiveActions=n),placeholder:"Corrective actions and preventive measures…"},null,512),[[e.vModelText,i.reportForm.correctiveActions]])]),e.createElementVNode("div",Sn,[t[127]||(t[127]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Any Other Remarks",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[35]||(t[35]=n=>i.reportForm.inc_remarks=n),placeholder:"Additional remarks…"},null,512),[[e.vModelText,i.reportForm.inc_remarks]])])])):(e.openBlock(),e.createElementBlock("div",Fn,[t[129]||(t[129]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Corrective Actions",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"3","onUpdate:modelValue":t[36]||(t[36]=n=>i.reportForm.correctiveActions=n),placeholder:"List any corrective actions required or taken…"},null,512),[[e.vModelText,i.reportForm.correctiveActions]])])),e.createElementVNode("div",un,[t[133]||(t[133]=e.createElementVNode("label",{class:"form-label fw-semibold"},[e.createTextVNode(" Attach Files "),e.createElementVNode("span",{class:"form-hint"},"Images embed in PDF · all files go into the ZIP")],-1)),e.createElementVNode("div",{class:"file-drop-zone",onClick:t[37]||(t[37]=n=>o.$refs.reportFileInput.click()),onDragover:t[38]||(t[38]=e.withModifiers(()=>{},["prevent"])),onDrop:t[39]||(t[39]=e.withModifiers((...n)=>s.handleReportFileDrop&&s.handleReportFileDrop(...n),["prevent"]))},[t[131]||(t[131]=e.createElementVNode("i",{class:"bi bi-cloud-upload",style:{"font-size":"2rem",color:"#6c757d"}},null,-1)),t[132]||(t[132]=e.createElementVNode("p",{class:"mb-0 mt-2 text-muted"},"Click or drag files here (PNG, JPG, PDF…)",-1)),i.reportForm.files.length>0?(e.openBlock(),e.createElementBlock("div",Bn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.reportForm.files,(n,a)=>(e.openBlock(),e.createElementBlock("span",{class:"attached-chip",key:a},[e.createElementVNode("i",{class:e.normalizeClass(["bi me-1",s.fileIcon(n.type)])},null,2),e.createTextVNode(e.toDisplayString(n.name)+" ",1),e.createElementVNode("button",{onClick:e.withModifiers(c=>s.removeReportFile(a),["stop"])},t[130]||(t[130]=[e.createElementVNode("i",{class:"bi bi-x"},null,-1)]),8,xn)]))),128))])):e.createCommentVNode("",!0)],32),e.createElementVNode("input",{ref:"reportFileInput",type:"file",multiple:"",style:{display:"none"},onChange:t[40]||(t[40]=(...n)=>s.handleReportFileAttach&&s.handleReportFileAttach(...n))},null,544)]),i.reportForm.title||i.reportForm.files.length>0?(e.openBlock(),e.createElementBlock("div",Tn,[t[134]||(t[134]=e.createElementVNode("i",{class:"bi bi-file-zip me-1"},null,-1)),t[135]||(t[135]=e.createTextVNode(" Download will produce ",-1)),e.createElementVNode("strong",null,e.toDisplayString(s.zipName)+".zip",1),t[136]||(t[136]=e.createTextVNode(" containing the report PDF ",-1)),i.reportForm.files.length?(e.openBlock(),e.createElementBlock("span",Rn," + "+e.toDisplayString(i.reportForm.files.length)+" attachment"+e.toDisplayString(i.reportForm.files.length!==1?"s":""),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",An,[e.createElementVNode("button",{type:"button",class:"btn btn-secondary",onClick:t[41]||(t[41]=(...n)=>s.closeReportForm&&s.closeReportForm(...n))},"Cancel"),e.createElementVNode("button",{type:"button",class:"btn btn-success",onClick:t[42]||(t[42]=(...n)=>s.requestSubmitReport&&s.requestSubmitReport(...n)),disabled:r.isSubmitting||!i.reportForm.title||!i.reportForm.submittedBy||!i.reportForm.findings},[r.isSubmitting?(e.openBlock(),e.createElementBlock("span",Mn,t[137]||(t[137]=[e.createElementVNode("span",{class:"spinner-sm"},null,-1),e.createTextVNode(" Submitting…",-1)]))):(e.openBlock(),e.createElementBlock("span",In,t[138]||(t[138]=[e.createElementVNode("i",{class:"bi bi-check-circle me-1"},null,-1),e.createTextVNode("Submit Report",-1)])))],8,Pn)])])])],2),e.createElementVNode("div",{class:e.normalizeClass(["modal",{show:i.showViewModal}]),onClick:t[48]||(t[48]=e.withModifiers((...n)=>s.closeViewer&&s.closeViewer(...n),["self"]))},[e.createElementVNode("div",Ln,[i.viewingReport?(e.openBlock(),e.createElementBlock("div",qn,[e.createElementVNode("div",zn,[e.createElementVNode("div",On,[e.createElementVNode("span",{class:e.normalizeClass(["entity-chip me-2",s.reportTypeClass(i.viewingReport)])},e.toDisplayString(s.reportTypeLabel(i.viewingReport)),3),e.createElementVNode("strong",Un,e.toDisplayString(i.viewingReport.title),1)]),e.createElementVNode("button",{type:"button",class:"btn-close btn-close-white",onClick:t[44]||(t[44]=(...n)=>s.closeViewer&&s.closeViewer(...n))})]),e.createElementVNode("div",jn,[e.createElementVNode("div",Gn,[e.createElementVNode("div",Hn,[t[139]||(t[139]=e.createElementVNode("label",null,"Reference",-1)),e.createElementVNode("span",Wn,e.toDisplayString(i.viewingReport.entityRef||"—"),1)]),e.createElementVNode("div",Qn,[t[140]||(t[140]=e.createElementVNode("label",null,"Type",-1)),e.createElementVNode("span",null,e.toDisplayString(s.reportTypeLabel(i.viewingReport)),1)]),i.viewingReport.manualCategory?(e.openBlock(),e.createElementBlock("div",Jn,[t[141]||(t[141]=e.createElementVNode("label",null,"Category",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.manualCategory),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Yn,[t[142]||(t[142]=e.createElementVNode("label",null,"Submitted By",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.submittedBy),1)]),e.createElementVNode("div",Zn,[t[143]||(t[143]=e.createElementVNode("label",null,"Date",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.date),1)]),i.viewingReport.vessel?(e.openBlock(),e.createElementBlock("div",Kn,[t[144]||(t[144]=e.createElementVNode("label",null,"Vessel / Location",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.vessel),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",$n,[t[145]||(t[145]=e.createElementVNode("label",null,"Submitted At",-1)),e.createElementVNode("span",null,e.toDisplayString(s.formatDate(i.viewingReport.submittedAt)),1)]),i.viewingReport.entity_subtype?(e.openBlock(),e.createElementBlock("div",Xn,[t[146]||(t[146]=e.createElementVNode("label",null,"Drill Type",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.entity_subtype),1)])):e.createCommentVNode("",!0),i.viewingReport.entity_creator?(e.openBlock(),e.createElementBlock("div",vn,[t[147]||(t[147]=e.createElementVNode("label",null,"Drill Master",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.entity_creator),1)])):e.createCommentVNode("",!0),i.viewingReport.entity_duration?(e.openBlock(),e.createElementBlock("div",ei,[t[148]||(t[148]=e.createElementVNode("label",null,"Duration",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.entity_duration),1)])):e.createCommentVNode("",!0),i.viewingReport.entity_participants?(e.openBlock(),e.createElementBlock("div",ti,[t[149]||(t[149]=e.createElementVNode("label",null,"Participants",-1)),e.createElementVNode("span",null,e.toDisplayString(i.viewingReport.entity_participants),1)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",oi,[t[150]||(t[150]=e.createElementVNode("label",null,"Findings / Summary",-1)),e.createElementVNode("div",ni,e.toDisplayString(i.viewingReport.findings),1)]),i.viewingReport.correctiveActions?(e.openBlock(),e.createElementBlock("div",ii,[t[151]||(t[151]=e.createElementVNode("label",null,"Corrective Actions",-1)),e.createElementVNode("div",si,e.toDisplayString(i.viewingReport.correctiveActions),1)])):e.createCommentVNode("",!0),s.getFilesForReport(i.viewingReport.id).length>0?(e.openBlock(),e.createElementBlock("div",li,[t[153]||(t[153]=e.createElementVNode("label",null,"Attachments",-1)),e.createElementVNode("div",ri,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.getFilesForReport(i.viewingReport.id),n=>(e.openBlock(),e.createElementBlock("a",{key:n.id,href:n.publicUrl,target:"_blank",rel:"noopener",class:"attached-chip attached-chip--link"},[e.createElementVNode("i",{class:e.normalizeClass(["bi me-1",s.fileIcon(n.type)])},null,2),e.createTextVNode(e.toDisplayString(n.name)+" ",1),e.createElementVNode("small",di,"("+e.toDisplayString(s.formatFileSize(n.size))+")",1),t[152]||(t[152]=e.createElementVNode("i",{class:"bi bi-box-arrow-up-right ms-1",style:{"font-size":"10px"}},null,-1))],8,ai))),128))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",ci,[e.createElementVNode("button",{class:"btn btn-danger btn-sm me-auto",onClick:t[45]||(t[45]=n=>s.requestDeleteReport(i.viewingReport.id))},t[154]||(t[154]=[e.createElementVNode("i",{class:"bi bi-trash"},null,-1),e.createTextVNode(" Delete ",-1)])),e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[46]||(t[46]=(...n)=>s.closeViewer&&s.closeViewer(...n))},"Close"),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[47]||(t[47]=n=>s.downloadReport(i.viewingReport)),disabled:i.generatingPdf===i.viewingReport.id},[i.generatingPdf===i.viewingReport.id?(e.openBlock(),e.createElementBlock("span",pi,t[155]||(t[155]=[e.createElementVNode("span",{class:"spinner-sm"},null,-1),e.createTextVNode(" Building ZIP…",-1)]))):(e.openBlock(),e.createElementBlock("span",fi,t[156]||(t[156]=[e.createElementVNode("i",{class:"bi bi-file-zip me-1"},null,-1),e.createTextVNode("Download ZIP",-1)])))],8,mi)])])):e.createCommentVNode("",!0)])],2),e.createElementVNode("input",{ref:"fileInput",type:"file",multiple:"",style:{display:"none"},onChange:t[49]||(t[49]=(...n)=>s.handleFileSelection&&s.handleFileSelection(...n))},null,544)])}const M=F(ze,[["render",hi],["__scopeId","data-v-9e048de6"]]),gi={name:"OceanHelmMaintenance",props:{vesselInfo:{type:Object,required:!0},tasks:{type:Array,default:()=>[]},vesselCrew:{type:Array,default:()=>[]},companyInfo:{type:Object,default:()=>({})},userProfile:{type:Object,required:!0}},emits:["dashboard-navigate","load-checklist","save-schedule","update-task","upload-file","delete-evidence","access-denied","show-message","generate-checklist"],data(){return{ready:!0,isSaving:!1,after:null,lastSection:"",currentTask:"",imgText:"Choose file to upload",fileText:"Drag and drop files here or",fileattachments:{},refreshKey:0,activeSection:"inventory",sections:[{id:"schedule",name:"Schedule",icon:"📅"},{id:"inventory",name:"All Maintenance",icon:"♻️"},{id:"dashboard",name:"Dashboard",icon:"☰",onClick:()=>this.$emit("dashboard-navigate")}],activeFilter:"all",searchQuery:"",checklists:[],isLoading:!1,form:{taskName:"",description:"",maintenanceType:"",component:"",priority:"",dueDate:"",estimatedHours:null,assignedTo:"",recurrence:"",lastPerformed:"",nextDue:"",notifyEmail:!0,notifySms:!0,reminderDays:"1",estimatedDuration:null,notes:"",status:"Soon",email:"",remainingDays:null,attachments:{}},maintenanceTasks:[],showReport:!1,reportDate:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),reportId:"MT-"+Math.random().toString(36).substr(2,9).toUpperCase()}},watch:{"form.lastPerformed":"calculateNextDue","form.recurrence":"calculateNextDue","form.nextDue":function(o){this.calculateRemainingDays()}},computed:{filteredTasks(){let o=[...this.tasks];if(this.activeFilter==="all"?o=o.filter(t=>t.status==="Overdue"||t.status==="Soon"||t.status==="Completed"):this.activeFilter==="due"?o=o.filter(t=>t.status==="Overdue"||t.status==="Soon"):this.activeFilter==="completed"&&(o=o.filter(t=>t.status==="Completed")),this.searchQuery){const t=this.searchQuery.toLowerCase();o=o.filter(r=>r.component.toLowerCase().includes(t)||r.taskName.toLowerCase().includes(t)||r.assignedTo.toLowerCase().includes(t))}return o},completedCount(){return this.checklists.filter(o=>o.completed)},progress(){return Math.round(this.completedCount.length/this.checklists.length*100)},checklistButtonLabel(){return this.lastSection==="schedule"?"Approve Maintenance":"Save Checklist"},showAddTaskButton(){return this.checklistButtonLabel!=="Save Checklist"},totalEstimatedHours(){return this.maintenanceTasks.reduce((o,t)=>o+(t.estimatedHours||0),0)}},methods:{grantAccess(o){const t=this.userProfile;return t.role==="owner"||t.role==="staff"||t.role==="captain"&&t.vessel===o},deepAccess(){const o=this.userProfile;return o.role==="owner"||o.role==="captain"?!0:(this.$emit("access-denied","You do not have access to do this"),!1)},deleteTask(o){this.checklists=this.checklists.filter(t=>t.id!==o)},addTask(o){o&&o.preventDefault(),this.$emit("show-message",{type:"prompt",title:"Add New Task",message:"Enter the task details",callback:t=>{if(t){const r={id:Date.now(),text:t,completed:!1};this.checklists.push(r)}}})},setFilter(o){this.activeFilter=o},loadChecklist(o){this.isLoading=!0,this.$emit("generate-checklist",{component:o,callback:t=>{this.checklists=t.map(r=>({...r,completed:!1})),this.isLoading=!1}})},showMaintenance(o){if(this.deepAccess()){const t=this.tasks.find(r=>r.component===o);t&&t.checklistProgress?this.checklists=[...t.checklistProgress]:this.loadChecklist(o),this.after=t==null?void 0:t.after,this.currentTask=o,this.lastSection="inventory",this.activeSection="maintenance"}},printMaintenance(o){const t=this.tasks.find(r=>r.component===o);this.maintenanceTasks=[t],this.loadMaintenanceData(),this.showReport=!0,this.$nextTick(()=>{setTimeout(()=>{window.print(),this.showReport=!1},100)})},switchSchedule(){this.deepAccess()&&(this.activeSection="schedule")},handleFiles(o){this.imgText=o.target.files[0].name,this.form.attachments={file:o.target.files[0]}},handleImg(o){this.fileText=o.target.files[0].name,this.fileattachments={file:o.target.files[0]}},validateForm(){const o=["taskName","description","maintenanceType","component","priority","estimatedHours","recurrence","lastPerformed","assignedTo"];for(const t of o)if(!this.form[t])return this.$emit("show-message",{type:"error",title:"Missing info",message:`Please fill in the required field: ${t}`}),!1;return!0},handleSectionClick(o){this.activeSection=o.id,typeof o.onClick=="function"&&o.onClick()},calculateNextDue(){const o=this.form.lastPerformed?new Date(this.form.lastPerformed):null,t=this.form.recurrence;if(!o||!t)return;let r=new Date(o);switch(t){case"daily":r.setDate(r.getDate()+1);break;case"weekly":r.setDate(r.getDate()+7);break;case"monthly":r.setMonth(r.getMonth()+1);break;case"quarterly":r.setMonth(r.getMonth()+3);break;case"semi-annual":r.setMonth(r.getMonth()+6);break;case"annual":r.setFullYear(r.getFullYear()+1);break;case"once":case"custom":return}this.form.nextDue=r.toISOString().split("T")[0]},calculateRemainingDays(){if(!this.form.nextDue){this.form.remainingDays=null;return}const o=new Date,t=new Date(this.form.nextDue);o.setHours(0,0,0,0),t.setHours(0,0,0,0);const r=t-o,l=Math.ceil(r/(1e3*60*60*24));this.form.remainingDays=`${l} Days`},async saveSchedule(){if(this.isSaving=!0,!this.validateForm()){this.isSaving=!1;return}const o={...this.form};if(this.form.component==="Other"&&this.form.customComponent&&(o.component=this.form.customComponent),o.email=this.companyInfo.email,this.tasks.some(r=>r.component===o.component)){this.$emit("show-message",{type:"error",title:"Duplicate Component",message:`A task with the component "${o.component}" already exists in maintenance`}),this.isSaving=!1;return}delete o.customComponent,this.$emit("save-schedule",{taskData:o,file:o.attachments.file,callback:r=>{this.isSaving=!1,r&&(this.loadChecklist(o.component),this.lastSection="schedule",this.currentTask=o.component,this.resetForm(),this.activeSection="maintenance")}})},resetForm(){this.form={taskName:"",description:"",maintenanceType:"",component:"",priority:"",dueDate:"",estimatedHours:null,assignedTo:"",recurrence:"",lastPerformed:"",nextDue:"",notifyEmail:!0,notifySms:!0,reminderDays:"1",estimatedDuration:null,notes:"",status:"Soon",remainingDays:null,attachments:{}}},toggleTask(o){o.completed=!o.completed},async resetTasks(){const t=this.checklists.every(l=>l.completed)?"Completed":"Soon",r={checklistProgress:[...this.checklists],status:t,component:this.currentTask,after:this.after};this.$emit("update-task",{updateData:r,file:this.fileattachments.file,tasks:this.tasks,callback:(l,i)=>{l&&(i&&(this.after=i),this.fileattachments={},this.fileText="Drag and drop files here or",this.refreshKey+=1,this.activeSection="inventory")}})},loadMaintenanceData(){this.reportId="MT-"+Math.random().toString(36).substr(2,9).toUpperCase(),this.reportDate=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})},formatDate(o){return o?new Date(o).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"N/A"},getTaskStatusClass(o){return o.status==="Completed"?"completed":o.status==="Overdue"?"overdue":o.status==="In Progress"?"in-progress":"pending"},getChecklistProgress(o){if(!o.checklistProgress||o.checklistProgress.length===0)return 0;const t=o.checklistProgress.filter(r=>r.completed).length;return Math.round(t/o.checklistProgress.length*100)},getCompletedChecklistItems(o){return o.checklistProgress?o.checklistProgress.filter(t=>t.completed).length:0},generateRecommendations(){return["Maintain regular communication with assigned technicians","Ensure all safety protocols are followed during maintenance activities","Update task progress and notes in real-time for accurate reporting"]},deleteEvidence(){this.$emit("delete-evidence",{currentTask:this.currentTask,callback:o=>{o&&(this.after=null,this.fileText="Drag and drop files here or",this.fileattachments={},this.refreshKey+=1)}})}}},yi={key:0},Ei=["onClick"],Ni={class:"content"},bi={key:0,class:"loading-container"},Vi={key:1},ki={class:"container"},wi={class:"d-flex justify-content-between align-items-center"},Ci={class:"progress-container"},Di={class:"progress-info"},_i={class:"progress-bar"},Si={class:"checklist"},Fi=["onClick"],ui={key:0},Bi=["onClick"],xi=["onClick"],Ti={key:0},Ri={class:"checklist"},Ai={class:"checklist-item"},Pi={class:"attachment-area"},Mi={key:2,class:"status"},Ii={class:"form-group"},Li={class:"form-group"},qi={class:"input-group"},zi={class:"form-group"},Oi={class:"form-group"},Ui={class:"input-group"},ji={class:"form-group"},Gi={class:"form-group"},Hi={class:"input-group"},Wi={class:"form-group"},Qi={class:"form-group"},Ji=["value"],Yi={class:"input-group"},Zi={class:"form-group"},Ki={class:"input-group"},$i={class:"form-group"},Xi={class:"form-group"},vi={class:"form-group"},es={class:"checkbox-group"},ts={class:"checkbox-item"},os={class:"checkbox-item"},ns={class:"input-group"},is={class:"form-group"},ss={class:"form-group"},ls={class:"form-group"},rs={class:"attachment-area"},as={class:"action-buttons"},ds=["disabled"],cs={class:"task-table-wrapper"},ms={class:"table-controls"},ps={class:"filters"},fs={class:"task-table"},hs=["onClick"],gs=["onClick"],ys={key:0},Es={class:"alert alert-primary",role:"alert"},Ns={class:"mb-0"},bs={class:"report-container",ref:"reportContainer"},Vs={class:"report-info"},ks={class:"info-box"},ws={class:"info-box"},Cs={class:"info-box"},Ds={class:"section"},_s={class:"summary-grid"},Ss={class:"summary-card"},Fs={class:"summary-number"},us={class:"section"},Bs={class:"task-header"},xs={class:"task-title"},Ts={class:"task-component"},Rs={class:"task-details"},As={class:"detail-item"},Ps={class:"detail-value"},Ms={class:"detail-item"},Is={class:"detail-value"},Ls={class:"detail-item"},qs={class:"detail-value"},zs={class:"detail-item"},Os={class:"detail-value"},Us={class:"detail-item"},js={class:"detail-value"},Gs={class:"detail-item"},Hs={class:"detail-value"},Ws={key:0,style:{margin:"15px 0",padding:"10px",background:"white","border-radius":"5px"}},Qs={class:"detail-value"},Js={key:1,style:{margin:"15px 0",padding:"10px",background:"white","border-radius":"5px"}},Ys={class:"detail-value"},Zs={key:2,class:"checklist-progress"},Ks={class:"progress-bar"},$s={style:{"font-size":"0.9em",color:"#666","margin-top":"5px"}},Xs={class:"checklist-items"},vs={class:"checklist-icon"},el={class:"section"},tl={class:"info-box"},ol={class:"signature-section"},nl={class:"signature-box"},il={style:{"margin-top":"10px",color:"#666"}};function sl(o,t,r,l,i,s){return i.ready?(e.openBlock(),e.createElementBlock("div",yi,[e.createElementVNode("div",null,[e.withDirectives(e.createElementVNode("nav",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.sections,n=>(e.openBlock(),e.createElementBlock("button",{key:n.id,class:e.normalizeClass(["nav-btn",{active:i.activeSection===n.id}]),onClick:a=>s.handleSectionClick(n)},e.toDisplayString(n.icon)+" "+e.toDisplayString(n.name),11,Ei))),128))],512),[[e.vShow,!i.showReport]]),e.withDirectives(e.createElementVNode("div",Ni,[e.withDirectives(e.createElementVNode("section",{class:e.normalizeClass(["form-section",{active:i.activeSection==="maintenance"}])},[t[37]||(t[37]=e.createElementVNode("h2",null,"🛠️ Maintenance Tasks",-1)),i.isLoading?(e.openBlock(),e.createElementBlock("div",bi,t[27]||(t[27]=[e.createElementVNode("div",{class:"loading-spinner"},null,-1),e.createElementVNode("p",null,"Loading checklist...",-1)]))):e.createCommentVNode("",!0),i.isLoading?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("form",Vi,[e.createElementVNode("div",ki,[e.createElementVNode("div",wi,[t[29]||(t[29]=e.createElementVNode("h1",null,"Maintenance Checklist",-1)),s.showAddTaskButton?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-outline-custom",onClick:t[0]||(t[0]=e.withModifiers(n=>s.addTask(),["prevent"]))},t[28]||(t[28]=[e.createTextVNode(" Manually Add Task ",-1),e.createElementVNode("i",{class:"fas fa-plus"},null,-1)]))):e.createCommentVNode("",!0)]),e.createElementVNode("div",Ci,[e.createElementVNode("div",Di," Progress: "+e.toDisplayString(s.progress)+"% ("+e.toDisplayString(s.completedCount.length)+"/"+e.toDisplayString(i.checklists.length)+") ",1),e.createElementVNode("div",_i,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:s.progress+"%"})},null,4)])]),e.createElementVNode("ul",Si,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.checklists,n=>(e.openBlock(),e.createElementBlock("li",{key:n.id,class:"checklist-item"},[e.createElementVNode("div",{class:e.normalizeClass(["checkbox",{checked:n.completed}]),onClick:a=>s.toggleTask(n)},[n.completed?(e.openBlock(),e.createElementBlock("span",ui,"✓")):e.createCommentVNode("",!0)],10,Fi),e.createElementVNode("span",{class:e.normalizeClass(["task-text",{completed:n.completed}]),onClick:a=>s.toggleTask(n)},e.toDisplayString(n.text),11,Bi),s.showAddTaskButton?(e.openBlock(),e.createElementBlock("button",{key:0,class:"delete-btn",onClick:a=>s.deleteTask(n.id),title:"Delete task"},t[30]||(t[30]=[e.createStaticVNode('<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3,6 5,6 21,6"></polyline><path d="m19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>',1)]),8,xi)):e.createCommentVNode("",!0)]))),128))]),i.after?(e.openBlock(),e.createElementBlock("div",Ti,[t[33]||(t[33]=e.createElementVNode("label",null,"Upload Image Evidence",-1)),e.createElementVNode("ul",Ri,[e.createElementVNode("li",Ai,[t[32]||(t[32]=e.createElementVNode("span",{class:"task-text"}," Image Evidence Already Uploaded ",-1)),e.createElementVNode("button",{type:"button",class:"delete-btn",onClick:t[1]||(t[1]=n=>s.deleteEvidence()),title:"Delete Image"},t[31]||(t[31]=[e.createStaticVNode('<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3,6 5,6 21,6"></polyline><path d="m19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>',1)]))])])])):(e.openBlock(),e.createElementBlock("div",{class:"form-group",key:i.refreshKey||"default"},[t[35]||(t[35]=e.createElementVNode("label",null,"Upload Image Evidence",-1)),t[36]||(t[36]=e.createElementVNode("p",null,"You can only upload one image evidence here.",-1)),e.createElementVNode("div",Pi,[e.createElementVNode("p",null,e.toDisplayString(i.fileText),1),e.createElementVNode("input",{type:"file",id:"evidence-files",class:"file-input",onChange:t[2]||(t[2]=(...n)=>s.handleImg&&s.handleImg(...n))},null,32),t[34]||(t[34]=e.createElementVNode("label",{for:"evidence-files",class:"file-label"},"Browse Files",-1))])])),s.completedCount===i.checklists.length?(e.openBlock(),e.createElementBlock("div",Mi," All tasks completed! ✅ ")):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"reset-button",onClick:t[3]||(t[3]=e.withModifiers((...n)=>s.resetTasks&&s.resetTasks(...n),["prevent"]))},e.toDisplayString(s.checklistButtonLabel),1)])]))],2),[[e.vShow,i.activeSection==="maintenance"]]),e.withDirectives(e.createElementVNode("section",{class:e.normalizeClass(["form-section",{active:i.activeSection==="schedule"}])},[t[62]||(t[62]=e.createElementVNode("h2",null,"📅 Maintenance Schedule",-1)),e.createElementVNode("form",null,[e.createElementVNode("div",Ii,[t[38]||(t[38]=e.createElementVNode("label",{for:"task-name"},"Task Name",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"task-name","onUpdate:modelValue":t[4]||(t[4]=n=>i.form.taskName=n),required:""},null,512),[[e.vModelText,i.form.taskName]])]),e.createElementVNode("div",Li,[t[39]||(t[39]=e.createElementVNode("label",{for:"task-description"},"Description",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"task-description","onUpdate:modelValue":t[5]||(t[5]=n=>i.form.description=n),required:""},null,512),[[e.vModelText,i.form.description]])]),e.createElementVNode("div",qi,[e.createElementVNode("div",zi,[t[41]||(t[41]=e.createElementVNode("label",{for:"maintenance-type"},"Maintenance Type",-1)),e.withDirectives(e.createElementVNode("select",{id:"maintenance-type","onUpdate:modelValue":t[6]||(t[6]=n=>i.form.maintenanceType=n),required:""},t[40]||(t[40]=[e.createStaticVNode('<option value="">-- Select Type --</option><option value="preventive">Preventive</option><option value="corrective">Corrective</option><option value="predictive">Predictive</option><option value="condition">Condition-Based</option>',5)]),512),[[e.vModelSelect,i.form.maintenanceType]])]),e.createElementVNode("div",Oi,[t[43]||(t[43]=e.createElementVNode("label",{for:"component"},"Component/System",-1)),e.withDirectives(e.createElementVNode("select",{id:"component","onUpdate:modelValue":t[7]||(t[7]=n=>i.form.component=n),required:""},t[42]||(t[42]=[e.createStaticVNode('<option value="">-- Select Component --</option><option value="engine">Engine</option><option value="hull">Hull</option><option value="electronics">Electronics</option><option value="deck">Deck Machinery</option><option value="plumbing">Plumbing</option><option value="electrical">Electrical</option><option value="hvac">HVAC</option><option value="safety">Safety Systems</option><option value="Other">Other</option>',10)]),512),[[e.vModelSelect,i.form.component]]),i.form.component==="Other"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,type:"text",placeholder:"Enter custom component/system","onUpdate:modelValue":t[8]||(t[8]=n=>i.form.customComponent=n),style:{"margin-top":"8px"}},null,512)),[[e.vModelText,i.form.customComponent]]):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Ui,[e.createElementVNode("div",ji,[t[45]||(t[45]=e.createElementVNode("label",{for:"priority"},"Priority",-1)),e.withDirectives(e.createElementVNode("select",{id:"priority","onUpdate:modelValue":t[9]||(t[9]=n=>i.form.priority=n),required:""},t[44]||(t[44]=[e.createElementVNode("option",{value:"low"},"Low",-1),e.createElementVNode("option",{value:"medium"},"Medium",-1),e.createElementVNode("option",{value:"high"},"High",-1),e.createElementVNode("option",{value:"critical"},"Critical",-1)]),512),[[e.vModelSelect,i.form.priority]])]),e.createElementVNode("div",Gi,[t[46]||(t[46]=e.createElementVNode("label",{for:"status"},"Status",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"status","onUpdate:modelValue":t[10]||(t[10]=n=>i.form.status=n),readonly:""},null,512),[[e.vModelText,i.form.status]])])]),e.createElementVNode("div",Hi,[e.createElementVNode("div",Wi,[t[47]||(t[47]=e.createElementVNode("label",{for:"estimated-hours"},"Estimated Hours",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",id:"estimated-hours","onUpdate:modelValue":t[11]||(t[11]=n=>i.form.estimatedHours=n),min:"0",step:"0.5"},null,512),[[e.vModelText,i.form.estimatedHours]])])]),e.createElementVNode("div",Qi,[t[49]||(t[49]=e.createElementVNode("label",{for:"assigned-to"},"Assigned To",-1)),e.withDirectives(e.createElementVNode("select",{id:"assigned-to","onUpdate:modelValue":t[12]||(t[12]=n=>i.form.assignedTo=n)},[t[48]||(t[48]=e.createElementVNode("option",{value:""},"-- Select Personnel --",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.vesselCrew,n=>(e.openBlock(),e.createElementBlock("option",{key:n.id,value:`${n.name} - ${n.role}`},e.toDisplayString(n.name)+" - "+e.toDisplayString(n.role),9,Ji))),128))],512),[[e.vModelSelect,i.form.assignedTo]])]),e.createElementVNode("div",Yi,[e.createElementVNode("div",Zi,[t[51]||(t[51]=e.createElementVNode("label",{for:"recurrence-type"},"Recurrence",-1)),e.withDirectives(e.createElementVNode("select",{id:"recurrence-type","onUpdate:modelValue":t[13]||(t[13]=n=>i.form.recurrence=n),required:""},t[50]||(t[50]=[e.createStaticVNode('<option value="once">One-time</option><option value="daily">Daily</option><option value="weekly">Weekly</option><option value="monthly">Monthly</option><option value="quarterly">Quarterly</option><option value="semi-annual">Semi-annually</option><option value="annual">Annually</option><option value="custom">Custom Interval</option>',8)]),512),[[e.vModelSelect,i.form.recurrence]])])]),e.createElementVNode("div",Ki,[e.createElementVNode("div",$i,[t[52]||(t[52]=e.createElementVNode("label",{for:"last-performed"},"Last Performed Date",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",id:"last-performed","onUpdate:modelValue":t[14]||(t[14]=n=>i.form.lastPerformed=n)},null,512),[[e.vModelText,i.form.lastPerformed]])]),e.createElementVNode("div",Xi,[t[53]||(t[53]=e.createElementVNode("label",{for:"next-due"},"Due Date",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",id:"next-due","onUpdate:modelValue":t[15]||(t[15]=n=>i.form.nextDue=n),required:""},null,512),[[e.vModelText,i.form.nextDue]])])]),e.createElementVNode("div",vi,[t[56]||(t[56]=e.createElementVNode("label",null,"Notifications",-1)),e.createElementVNode("div",es,[e.createElementVNode("div",ts,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"notify-email","onUpdate:modelValue":t[16]||(t[16]=n=>i.form.notifyEmail=n)},null,512),[[e.vModelCheckbox,i.form.notifyEmail]]),t[54]||(t[54]=e.createElementVNode("label",{for:"notify-email"},"Email Notification",-1))]),e.createElementVNode("div",os,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"notify-sms","onUpdate:modelValue":t[17]||(t[17]=n=>i.form.notifySms=n)},null,512),[[e.vModelCheckbox,i.form.notifySms]]),t[55]||(t[55]=e.createElementVNode("label",{for:"notify-sms"},"SMS Notification",-1))])])]),e.createElementVNode("div",ns,[e.createElementVNode("div",is,[t[58]||(t[58]=e.createElementVNode("label",{for:"reminder-days"},"Reminder (Days Before)",-1)),e.withDirectives(e.createElementVNode("select",{id:"reminder-days","onUpdate:modelValue":t[18]||(t[18]=n=>i.form.reminderDays=n)},t[57]||(t[57]=[e.createStaticVNode('<option value="1">1 day</option><option value="3">3 days</option><option value="7">1 week</option><option value="14">2 weeks</option><option value="30">1 month</option>',5)]),512),[[e.vModelSelect,i.form.reminderDays]])])]),e.createElementVNode("div",ss,[t[59]||(t[59]=e.createElementVNode("label",{for:"schedule-notes"},"Notes",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"schedule-notes","onUpdate:modelValue":t[19]||(t[19]=n=>i.form.notes=n)},null,512),[[e.vModelText,i.form.notes]])]),e.createElementVNode("div",ls,[t[61]||(t[61]=e.createElementVNode("label",null,"Attachments",-1)),e.createElementVNode("div",rs,[e.createElementVNode("p",null,e.toDisplayString(i.imgText),1),e.createElementVNode("input",{type:"file",id:"maintenance-files",class:"file-input",onChange:t[20]||(t[20]=(...n)=>s.handleFiles&&s.handleFiles(...n)),multiple:""},null,32),t[60]||(t[60]=e.createElementVNode("label",{for:"maintenance-files",class:"file-label"},"Browse Files",-1))])]),e.createElementVNode("div",as,[e.createElementVNode("button",{type:"button",class:"btn btn-primary",onClick:t[21]||(t[21]=e.withModifiers((...n)=>s.saveSchedule&&s.saveSchedule(...n),["prevent"])),disabled:i.isSaving},e.toDisplayString(i.isSaving?"Saving...":"Save Schedule"),9,ds)])])],2),[[e.vShow,i.activeSection==="schedule"]]),e.withDirectives(e.createElementVNode("section",{class:e.normalizeClass(["form-section",{active:i.activeSection==="inventory"}])},[t[68]||(t[68]=e.createElementVNode("h2",null,"All Maintenance",-1)),e.createElementVNode("div",cs,[e.createElementVNode("div",ms,[e.createElementVNode("div",ps,[e.createElementVNode("button",{class:e.normalizeClass({active:i.activeFilter==="due"}),onClick:t[22]||(t[22]=n=>s.setFilter("due"))},"Due",2),e.createElementVNode("button",{class:e.normalizeClass({active:i.activeFilter==="all"}),onClick:t[23]||(t[23]=n=>s.setFilter("all"))},"All",2),e.createElementVNode("button",{class:e.normalizeClass({active:i.activeFilter==="completed"}),onClick:t[24]||(t[24]=n=>s.setFilter("completed"))},"Completed",2),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":t[25]||(t[25]=n=>i.searchQuery=n),placeholder:"Search..."},null,512),[[e.vModelText,i.searchQuery]])])]),e.createElementVNode("table",fs,[t[63]||(t[63]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Equipment"),e.createElementVNode("th",null,"Task Name"),e.createElementVNode("th",null,"Assigned To"),e.createElementVNode("th",null,"Intervals"),e.createElementVNode("th",null,"Remaining"),e.createElementVNode("th",null,"Next Due"),e.createElementVNode("th",null,"Status"),e.createElementVNode("th",null,"Action")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.filteredTasks,n=>(e.openBlock(),e.createElementBlock("tr",{key:n.id},[e.createElementVNode("td",null,e.toDisplayString(n.component),1),e.createElementVNode("td",null,e.toDisplayString(n.taskName),1),e.createElementVNode("td",null,e.toDisplayString(n.assignedTo),1),e.createElementVNode("td",null,e.toDisplayString(n.recurrence),1),e.createElementVNode("td",null,e.toDisplayString(n.remainingDays),1),e.createElementVNode("td",null,e.toDisplayString(n.nextDue),1),e.createElementVNode("td",null,[e.createElementVNode("span",{class:e.normalizeClass(["status-badge",n.status.toLowerCase().replace(" ","-")])},e.toDisplayString(n.status),3)]),e.createElementVNode("td",null,[n.status==="Completed"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:a=>s.printMaintenance(n.component),class:"status-action"},"Print",8,hs)):(e.openBlock(),e.createElementBlock("button",{key:1,onClick:a=>s.showMaintenance(n.component),class:"status-action"},"Start",8,gs))])]))),128))])]),r.tasks.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ys,[e.createElementVNode("div",Es,[t[65]||(t[65]=e.createElementVNode("h4",{class:"alert-heading"},"Such Empty!!!",-1)),t[66]||(t[66]=e.createElementVNode("p",null,"You have no maintenance, because you have not scheduled any for this ship.",-1)),t[67]||(t[67]=e.createElementVNode("hr",null,null,-1)),e.createElementVNode("p",Ns,[t[64]||(t[64]=e.createTextVNode("Navigate to the schedule tab, to start scheduling. Or click on this button to ",-1)),e.createElementVNode("button",{type:"button",class:"btn btn-primary",onClick:t[26]||(t[26]=n=>s.switchSchedule())},"Schedule")])])]))])],2),[[e.vShow,i.activeSection==="inventory"]])],512),[[e.vShow,!i.showReport]]),e.withDirectives(e.createElementVNode("div",bs,[t[89]||(t[89]=e.createElementVNode("div",{class:"header"},[e.createElementVNode("div",{class:"report-title"},"MAINTENANCE TASK REPORT")],-1)),e.createElementVNode("div",Vs,[e.createElementVNode("div",ks,[t[69]||(t[69]=e.createElementVNode("div",{class:"info-label"},"Report Generated:",-1)),e.createElementVNode("div",null,e.toDisplayString(i.reportDate),1)]),e.createElementVNode("div",ws,[t[70]||(t[70]=e.createElementVNode("div",{class:"info-label"},"Report ID:",-1)),e.createElementVNode("div",null,e.toDisplayString(i.reportId),1)]),e.createElementVNode("div",Cs,[t[71]||(t[71]=e.createElementVNode("div",{class:"info-label"},"Total Tasks:",-1)),e.createElementVNode("div",null,e.toDisplayString(i.maintenanceTasks.length),1)]),t[72]||(t[72]=e.createElementVNode("div",{class:"info-box"},[e.createElementVNode("div",{class:"info-label"},"Generated By:"),e.createElementVNode("div",null,"OceanHelm System")],-1))]),e.createElementVNode("div",Ds,[t[75]||(t[75]=e.createElementVNode("div",{class:"section-title"},"📊 Task Summary",-1)),e.createElementVNode("div",_s,[t[74]||(t[74]=e.createStaticVNode('<div class="summary-card"><div class="summary-number">1</div><div class="summary-label">Completed</div></div><div class="summary-card"><div class="summary-number">0</div><div class="summary-label">Pending</div></div><div class="summary-card"><div class="summary-number">0</div><div class="summary-label">Overdue</div></div>',3)),e.createElementVNode("div",Ss,[e.createElementVNode("div",Fs,e.toDisplayString(s.totalEstimatedHours),1),t[73]||(t[73]=e.createElementVNode("div",{class:"summary-label"},"Total Hours",-1))])])]),e.createElementVNode("div",us,[t[85]||(t[85]=e.createElementVNode("div",{class:"section-title"},"🔧 Maintenance Tasks",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.maintenanceTasks,n=>(e.openBlock(),e.createElementBlock("div",{key:n.taskName,class:e.normalizeClass(["task-item",s.getTaskStatusClass(n)])},[e.createElementVNode("div",Bs,[e.createElementVNode("div",null,[e.createElementVNode("div",xs,[e.createTextVNode(e.toDisplayString(n.taskName)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["maintenance-type","type-"+n.maintenanceType])},e.toDisplayString(n.maintenanceType),3)]),e.createElementVNode("div",Ts,"Component: "+e.toDisplayString(n.component),1)]),e.createElementVNode("span",{class:e.normalizeClass(["status-badge","status-"+n.status.toLowerCase().replace(" ","-")])},e.toDisplayString(n.status),3)]),e.createElementVNode("div",Rs,[e.createElementVNode("div",As,[t[76]||(t[76]=e.createElementVNode("div",{class:"detail-label"},"Assigned To",-1)),e.createElementVNode("div",Ps,e.toDisplayString(n.assignedTo),1)]),e.createElementVNode("div",Ms,[t[77]||(t[77]=e.createElementVNode("div",{class:"detail-label"},"Estimated Hours",-1)),e.createElementVNode("div",Is,e.toDisplayString(n.estimatedHours)+" hours",1)]),e.createElementVNode("div",Ls,[t[78]||(t[78]=e.createElementVNode("div",{class:"detail-label"},"Last Performed",-1)),e.createElementVNode("div",qs,e.toDisplayString(s.formatDate(n.lastPerformed)),1)]),e.createElementVNode("div",zs,[t[79]||(t[79]=e.createElementVNode("div",{class:"detail-label"},"Next Due",-1)),e.createElementVNode("div",Os,e.toDisplayString(s.formatDate(n.nextDue)),1)]),e.createElementVNode("div",Us,[t[80]||(t[80]=e.createElementVNode("div",{class:"detail-label"},"Recurrence",-1)),e.createElementVNode("div",js,e.toDisplayString(n.recurrence),1)]),e.createElementVNode("div",Gs,[t[81]||(t[81]=e.createElementVNode("div",{class:"detail-label"},"Remaining Days",-1)),e.createElementVNode("div",Hs,e.toDisplayString(n.remainingDays)+" days",1)])]),n.description?(e.openBlock(),e.createElementBlock("div",Ws,[t[82]||(t[82]=e.createElementVNode("div",{class:"detail-label"},"Description",-1)),e.createElementVNode("div",Qs,e.toDisplayString(n.description),1)])):e.createCommentVNode("",!0),n.notes?(e.openBlock(),e.createElementBlock("div",Js,[t[83]||(t[83]=e.createElementVNode("div",{class:"detail-label"},"Notes",-1)),e.createElementVNode("div",Ys,e.toDisplayString(n.notes),1)])):e.createCommentVNode("",!0),n.checklistProgress&&n.checklistProgress.length>0?(e.openBlock(),e.createElementBlock("div",Zs,[t[84]||(t[84]=e.createElementVNode("div",{class:"detail-label"},"Checklist Progress",-1)),e.createElementVNode("div",Ks,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:s.getChecklistProgress(n)+"%"})},null,4)]),e.createElementVNode("div",$s,e.toDisplayString(s.getCompletedChecklistItems(n))+" of "+e.toDisplayString(n.checklistProgress.length)+" items completed ("+e.toDisplayString(s.getChecklistProgress(n))+"%) ",1),e.createElementVNode("div",Xs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.checklistProgress,(a,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"checklist-item"},[e.createElementVNode("span",vs,e.toDisplayString(a.completed?"✅":"⭕"),1),e.createElementVNode("span",null,e.toDisplayString(a.text||"Checklist Item "+(c+1)),1)]))),128))])])):e.createCommentVNode("",!0)],2))),128))]),e.createElementVNode("div",el,[t[86]||(t[86]=e.createElementVNode("div",{class:"section-title"},"📋 Recommendations",-1)),e.createElementVNode("div",tl,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.generateRecommendations(),n=>(e.openBlock(),e.createElementBlock("li",{key:n},e.toDisplayString(n),1))),128))])])]),e.createElementVNode("div",ol,[t[88]||(t[88]=e.createElementVNode("div",{class:"signature-box"},[e.createElementVNode("div",null,[e.createElementVNode("strong",null,"Report Generated By")]),e.createElementVNode("div",{style:{"margin-top":"10px",color:"#666"}},"OceanHelm Maintenance System")],-1)),e.createElementVNode("div",nl,[t[87]||(t[87]=e.createElementVNode("div",null,[e.createElementVNode("strong",null,"Date")],-1)),e.createElementVNode("div",il,e.toDisplayString(i.reportDate),1)])])],512),[[e.vShow,i.showReport]])])])):e.createCommentVNode("",!0)}const I=F(gi,[["render",sl]]),Vm="",ll={name:"ActivityLogs",props:{loading:Boolean,searchTerm:String,selectedFilter:String,logs:Array,paginatedLogs:Array,totalActivities:Number,todayActivities:Number,activeUsers:Number,totalPages:Number,currentPage:Number},emits:["update:searchTerm","update:selectedFilter","refresh","download","change-page"],methods:{formatDate(o){return new Date(o).toLocaleString()},getBadgeClass(o){return{login:"badge-login",logout:"badge-logout",create:"badge-create",update:"badge-update",delete:"badge-delete",view:"badge-view"}[o]||"badge-view"}}},rl={class:"activity-logs"},al={class:"a-controls"},dl={class:"a-search-box"},cl=["value"],ml=["value"],pl={class:"stats-grid"},fl={class:"stat-card"},hl={class:"value"},gl={class:"stat-card"},yl={class:"value"},El={class:"stat-card"},Nl={class:"value"},bl={class:"logs-container"},Vl={key:0,class:"loading"},kl={key:1,class:"no-logs"},wl={key:2},Cl={class:"logs-table"},Dl={style:{color:"gray"}},_l={style:{color:"gray"}},Sl={class:"pagination"},Fl=["disabled"],ul=["onClick"],Bl=["disabled"];function xl(o,t,r,l,i,s){return e.openBlock(),e.createElementBlock("div",rl,[e.createElementVNode("div",al,[e.createElementVNode("div",dl,[e.createElementVNode("input",{type:"text",placeholder:"Search activities, users, or actions...",value:r.searchTerm,onInput:t[0]||(t[0]=n=>o.$emit("update:searchTerm",n.target.value))},null,40,cl)]),e.createElementVNode("select",{class:"filter-select",value:r.selectedFilter,onChange:t[1]||(t[1]=n=>o.$emit("update:selectedFilter",n.target.value))},t[6]||(t[6]=[e.createStaticVNode('<option value="all">All Activities</option><option value="login">Login</option><option value="logout">Logout</option><option value="create">Create</option><option value="update">Update</option><option value="delete">Delete</option><option value="view">View</option>',7)]),40,ml),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[2]||(t[2]=n=>o.$emit("refresh"))},"🔄 Refresh"),e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[3]||(t[3]=n=>o.$emit("download"))},"📥 Download Report")]),e.createElementVNode("div",pl,[e.createElementVNode("div",fl,[t[7]||(t[7]=e.createElementVNode("h3",null,"Total Activities",-1)),e.createElementVNode("div",hl,e.toDisplayString(r.totalActivities),1)]),e.createElementVNode("div",gl,[t[8]||(t[8]=e.createElementVNode("h3",null,"Today's Activities",-1)),e.createElementVNode("div",yl,e.toDisplayString(r.todayActivities),1)]),e.createElementVNode("div",El,[t[9]||(t[9]=e.createElementVNode("h3",null,"Active Users",-1)),e.createElementVNode("div",Nl,e.toDisplayString(r.activeUsers),1)]),t[10]||(t[10]=e.createElementVNode("div",{class:"stat-card"},[e.createElementVNode("h3",null,"Important"),e.createElementVNode("div",{class:"badge-danger"}," Logs are deleted at the end of every month, please download a copy ")],-1))]),e.createElementVNode("div",bl,[r.loading?(e.openBlock(),e.createElementBlock("div",Vl,t[11]||(t[11]=[e.createElementVNode("div",{class:"spinner"},null,-1),e.createElementVNode("p",null,"Loading activity logs...",-1)]))):r.logs.length===0?(e.openBlock(),e.createElementBlock("div",kl,t[12]||(t[12]=[e.createElementVNode("h3",null,"No activities found",-1),e.createElementVNode("p",null,"Try adjusting your search or filter criteria",-1)]))):(e.openBlock(),e.createElementBlock("div",wl,[e.createElementVNode("table",Cl,[t[13]||(t[13]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Timestamp"),e.createElementVNode("th",null,"User Name"),e.createElementVNode("th",null,"Action"),e.createElementVNode("th",null,"Details"),e.createElementVNode("th",null,"Section")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.paginatedLogs,n=>(e.openBlock(),e.createElementBlock("tr",{key:n.id},[e.createElementVNode("td",null,e.toDisplayString(s.formatDate(n.timestamp)),1),e.createElementVNode("td",null,[e.createElementVNode("div",null,e.toDisplayString(n.user_name),1),e.createElementVNode("small",Dl,e.toDisplayString(n.email),1)]),e.createElementVNode("td",null,[e.createElementVNode("span",{class:e.normalizeClass(["activity-badge",s.getBadgeClass(n.action)])},e.toDisplayString(n.action),3)]),e.createElementVNode("td",null,[e.createTextVNode(e.toDisplayString(n.details.status)+" ",1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.details.information,(a,c)=>(e.openBlock(),e.createElementBlock("div",{key:c},[e.createElementVNode("strong",null,e.toDisplayString(c)+": ",1),e.createElementVNode("small",_l,e.toDisplayString((a==null?void 0:a.from)??"")+" → "+e.toDisplayString((a==null?void 0:a.to)??a??""),1)]))),128))]),e.createElementVNode("td",null,e.toDisplayString(n.table_name),1)]))),128))])]),e.createElementVNode("div",Sl,[e.createElementVNode("button",{onClick:t[4]||(t[4]=n=>o.$emit("change-page",r.currentPage-1)),disabled:r.currentPage===1}," Previous ",8,Fl),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.totalPages,n=>(e.openBlock(),e.createElementBlock("button",{key:n,onClick:a=>o.$emit("change-page",n),class:e.normalizeClass({active:r.currentPage===n})},e.toDisplayString(n),11,ul))),128)),e.createElementVNode("button",{onClick:t[5]||(t[5]=n=>o.$emit("change-page",r.currentPage+1)),disabled:r.currentPage===r.totalPages}," Next ",8,Bl)])]))])])}const L=F(ll,[["render",xl]]),km="",Tl={name:"CrewManagement",props:{crew:{type:Array,required:!0,default:()=>[]},vesselName:{type:String,default:""},currentCompanyId:{type:String,required:!0,default:""},userProfile:{type:Object,default:()=>({role:"viewer"})},loading:{type:Boolean,default:!1},availableRoles:{type:Array,default:()=>["Captain","First Officer","Engineer","Deckhand","Mechanic","Cook"]},config:{type:Object,default:()=>({showWaveBackground:!0,enableAdd:!0,enableEdit:!0,enableDelete:!0,enableAssignShift:!0,enableCertificationManagement:!0})}},emits:["crew-add","crew-edit","crew-delete","view-pending-certifications","crew-assign-shift","crew-deboard","crew-checkin","crew-add-certification","crew-view-certification","search-changed","filter-changed","access-denied","upload-cert-image","guest-checkin","guest-checkout"],data(){return{searchQuery:"",filterStatus:"all",showAddForm:!1,showGuestForm:!1,formErrors:{},guestFormErrors:{},expandedLogs:[],showTimesheet:!1,timesheetFilter:"all",timesheetSearch:"",timesheetSortKey:"timestamp",timesheetSortOrder:"desc",newCrew:{name:"",role:"Deckhand",customRole:"",status:"available",nextShift:"",certifications:[{name:"",expiryDate:"",imageFile:null,imagePreview:null,imageName:"",imageType:""}],notes:"",email:"",onBoard:""},newGuest:{name:"",email:"",vessel:"",arrivalDate:"",expectedDays:"",notes:""}}},computed:{sectionTitle(){return this.vesselName?`Current Crew for ${this.vesselName}`:"All Fleet Crew"},getApprovedCertifications(){return o=>!o.certifications||o.certifications.length===0?[]:o.certifications.filter(t=>{if(!t.verifications||t.verifications.length===0)return!1;const r=t.verifications.find(l=>l.companyId===this.currentCompanyId);return r&&r.status==="approved"})},filteredCrew(){return this.crew.filter(o=>{const t=this.searchQuery===""||o.name.toLowerCase().includes(this.searchQuery.toLowerCase())||o.role.toLowerCase().includes(this.searchQuery.toLowerCase())||o.vessel&&o.vessel.toLowerCase().includes(this.searchQuery.toLowerCase()),r=this.filterStatus==="all"||o.status===this.filterStatus;return t&&r})},allTimesheetEntries(){const o=[];return this.crew.forEach(t=>{t.log&&t.log.length>0&&t.log.forEach((r,l)=>{o.push({...r,crewName:t.name,role:t.role,crewId:t.id,uniqueId:`${t.id}-${l}`})})}),o.sort((t,r)=>{const l=new Date(t.timestamp),i=new Date(r.timestamp);return this.timesheetSortOrder==="desc"?i-l:l-i})},filteredTimesheetEntries(){let o=this.allTimesheetEntries;if(this.timesheetFilter!=="all"&&(o=o.filter(t=>t.action===this.timesheetFilter)),this.timesheetSearch){const t=this.timesheetSearch.toLowerCase();o=o.filter(r=>r.crewName.toLowerCase().includes(t)||r.role.toLowerCase().includes(t)||r.action.toLowerCase().includes(t)||r.vessel&&r.vessel.toLowerCase().includes(t)||r.notes&&r.notes.toLowerCase().includes(t))}return this.sortTimesheetEntries(o)},uniqueCrewCount(){return new Set(this.filteredTimesheetEntries.map(t=>t.crewId)).size},timesheetDateRange(){if(this.filteredTimesheetEntries.length===0)return"N/A";const o=this.filteredTimesheetEntries.map(i=>new Date(i.timestamp)),t=new Date(Math.min(...o)),r=new Date(Math.max(...o)),l=i=>i.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return`${l(t)} - ${l(r)}`},canAddCrew(){return this.config.enableAdd&&this.hasPermission("add")},canEditCrew(){return this.config.enableEdit&&this.hasPermission("edit")},canDeleteCrew(){return this.config.enableDelete&&this.hasPermission("delete")},canAssignShift(){return this.config.enableAssignShift&&this.hasPermission("assign")},canDeboardCrew(){return this.config.enableAssignShift&&this.hasPermission("assign")},currentDate(){return new Date().toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})},totalOnboard(){return this.crew.filter(o=>o.status==="onboard").length},crewOnboard(){return this.crew.filter(o=>o.status==="onboard"&&o.role!=="guest").length},guestsOnboard(){return this.crew.filter(o=>o.status==="onboard"&&o.role==="guest").length},personnelByVessel(){const o={};return this.crew.forEach(t=>{t.status==="onboard"&&t.vessel&&(o[t.vessel]||(o[t.vessel]={crew:0,guests:0,total:0}),t.role==="guest"?o[t.vessel].guests++:o[t.vessel].crew++,o[t.vessel].total++)}),o},availableVessels(){const o=new Set;return this.crew.forEach(t=>{t.vessel&&t.vessel.trim()!==""&&o.add(t.vessel)}),Array.from(o).sort()}},methods:{hasPermission(o){const{role:t,vessel:r}=this.userProfile,l=r===this.vesselName;let s={owner:["add","edit","delete","assign","view"],staff:["add","edit","assign","view"],captain:["assign","view"],viewer:["view"]}[t]||[];return t==="captain"&&l&&(s=[...s,"add"]),s.includes(o)},getEmbarkationDate(o){return["onboard","onduty","assigned"].includes(o.status)?o.nextShift||"Not Scheduled":"N/A"},getDaysOnboard(o){if(o.status!=="onboard"||!o.log||o.log.length===0)return"N/A";let t=null;for(let n=o.log.length-1;n>=0;n--)if(o.log[n].action==="Onboard"){t=o.log[n];break}if(!t||!t.timestamp)return"N/A";const r=new Date(t.timestamp),i=Math.abs(new Date-r);return Math.floor(i/(1e3*60*60*24))},getGuestDaysOnboard(o){if(!o.nextShift||o.status!=="onboard")return"N/A";const t=new Date(o.nextShift),l=Math.abs(new Date-t);return Math.floor(l/(1e3*60*60*24))},getPendingCertificationsCount(o){return!o.certifications||o.certifications.length===0?0:o.certifications.filter(t=>{if(!t.verifications||t.verifications.length===0)return!0;const r=t.verifications.find(l=>l.companyId===this.currentCompanyId);return!r||r.status==="pending"}).length},handleViewPendingCertifications(o){this.$emit("view-pending-certifications",{memberId:o.id,memberName:o.name,companyId:this.currentCompanyId})},handleToggleAddForm(){if(!this.canAddCrew){this.$emit("access-denied",{action:"add crew",userProfile:this.userProfile});return}this.showAddForm=!this.showAddForm,this.showAddForm||this.resetForm()},handleToggleGuestForm(){if(!this.canAddCrew){this.$emit("access-denied",{action:"check-in guest",userProfile:this.userProfile});return}this.showGuestForm=!this.showGuestForm,this.showGuestForm||this.resetGuestForm()},handleCheckinGuest(){if(!this.validateGuestForm())return;const o={name:this.newGuest.name,role:"guest",status:"onboard",nextShift:this.newGuest.arrivalDate,onBoard:this.newGuest.expectedDays,email:this.newGuest.email||"",notes:this.newGuest.notes,vessel:this.vesselName||this.newGuest.vessel,certifications:[]};this.$emit("guest-checkin",o),this.resetGuestForm(),this.showGuestForm=!1},handleCheckoutGuest(o){if(!this.canDeboardCrew){this.$emit("access-denied",{action:"check out guest",userProfile:this.userProfile});return}let t=null;if(o.nextShift){const r=new Date(o.nextShift),i=Math.abs(new Date-r);t=Math.ceil(i/(1e3*60*60*24))}this.$emit("guest-checkout",{member:o,duration:t})},handleCancelGuestForm(){this.showGuestForm=!1,this.resetGuestForm()},resetGuestForm(){this.newGuest={name:"",email:"",vessel:"",arrivalDate:"",expectedDays:"",notes:""},this.guestFormErrors={}},validateGuestForm(){return this.guestFormErrors={},(!this.newGuest.name||this.newGuest.name.trim()==="")&&(this.guestFormErrors.name="Guest name is required"),!this.vesselName&&(!this.newGuest.vessel||this.newGuest.vessel.trim()==="")&&(this.guestFormErrors.vessel="Please select a vessel"),this.newGuest.arrivalDate||(this.guestFormErrors.arrivalDate="Arrival date is required"),(!this.newGuest.expectedDays||this.newGuest.expectedDays<=0)&&(this.guestFormErrors.expectedDays="Expected days onboard must be at least 1"),Object.keys(this.guestFormErrors).length>0?(this.$emit("validation-error",this.guestFormErrors),!1):!0},handleSearch(){this.$emit("search-changed",this.searchQuery)},handleFilter(){this.$emit("filter-changed",this.filterStatus)},filterTimesheet(){},sortTimesheet(o){this.timesheetSortKey===o?this.timesheetSortOrder=this.timesheetSortOrder==="asc"?"desc":"asc":(this.timesheetSortKey=o,this.timesheetSortOrder="asc")},sortTimesheetEntries(o){const t=[...o];return t.sort((r,l)=>{let i,s;switch(this.timesheetSortKey){case"timestamp":i=new Date(r.timestamp),s=new Date(l.timestamp);break;case"crewName":i=r.crewName.toLowerCase(),s=l.crewName.toLowerCase();break;case"role":i=r.role.toLowerCase(),s=l.role.toLowerCase();break;case"action":i=r.action.toLowerCase(),s=l.action.toLowerCase();break;default:return 0}return i<s?this.timesheetSortOrder==="asc"?-1:1:i>s?this.timesheetSortOrder==="asc"?1:-1:0}),t},getTimesheetRowClass(o){return`timesheet-row-${o.toLowerCase().replace(/\s+/g,"-")}`},async handleAddCrewMember(){if(!this.validateForm())return;if(this.newCrew.certifications.some(s=>{const n=s.name.trim()!=="",a=s.expiryDate!=="",c=s.imageFile!==null;return(n||a||c)&&!(n&&a&&c)})){this.$emit("incomplete-certification");return}const t=this.newCrew.certifications.filter(s=>s.name.trim()!==""&&s.expiryDate!==""&&s.imageFile!==null),r=this.newCrew.role==="Other"?this.newCrew.customRole:this.newCrew.role,l=await Promise.all(t.map(async(s,n)=>{const a=await this.uploadCertificationImage(s.imageFile,this.newCrew.email);return{name:s.name,expiryDate:s.expiryDate,imageName:s.imageName,imageType:s.imageType,imageUrl:a.publicUrl}})),i={name:this.newCrew.name,role:r,status:"unavailable",certifications:l,notes:this.newCrew.notes,vessel:this.vesselName,email:this.newCrew.email,onBoard:this.newCrew.onBoard,nextShift:this.newCrew.nextShift};this.$emit("crew-add",i),this.resetForm(),this.showAddForm=!1},async uploadCertificationImage(o,t){return new Promise((r,l)=>{this.$emit("upload-cert-image",{file:o,email:t,callback:i=>{i.error?l(i.error):r(i)}})})},handleCancelForm(){this.showAddForm=!1,this.resetForm()},handleDeleteCrew(o){if(!this.canDeleteCrew){this.$emit("access-denied",{action:"delete crew",userProfile:this.userProfile});return}this.$emit("crew-delete",o)},handleAssignShift(o){if(!this.canAssignShift){this.$emit("access-denied",{action:"assign shift",userProfile:this.userProfile});return}this.$emit("crew-assign-shift",o)},handleDeboardCrew(o){if(!this.canDeboardCrew){this.$emit("access-denied",{action:"deboard crew",userProfile:this.userProfile});return}let t=null;if(o.nextShift){const r=new Date(o.nextShift),i=Math.abs(new Date-r);t=Math.ceil(i/(1e3*60*60*24))}this.$emit("crew-deboard",{member:o,duration:t})},handleCheckinCrew(o){if(!this.canDeboardCrew){this.$emit("access-denied",{action:"check in crew",userProfile:this.userProfile});return}this.$emit("crew-checkin",o)},toggleCrewLog(o){const t=this.expandedLogs.indexOf(o);t>-1?this.expandedLogs.splice(t,1):this.expandedLogs.push(o)},handleAddCertification(o){if(!this.canEditCrew){this.$emit("access-denied",{action:"add certification",userProfile:this.userProfile});return}this.$emit("crew-add-certification",o)},handleViewCertification(o,t){this.$emit("crew-view-certification",{certification:o,member:t})},resetForm(){this.newCrew={name:"",role:"Deckhand",customRole:"",status:"Unavailable",nextShift:"",certifications:[{name:"",expiryDate:"",imageFile:null,imagePreview:null,imageName:"",imageType:""}],notes:"",email:"",onBoard:""},this.formErrors={}},validateForm(){this.formErrors={};const o={name:"Full Name",email:"Email Address"};return Object.keys(o).forEach(t=>{(!this.newCrew[t]||this.newCrew[t].trim()==="")&&(this.formErrors[t]=`${o[t]} is required`)}),this.newCrew.email&&!this.isValidEmail(this.newCrew.email)&&(this.formErrors.email="Please enter a valid email address"),this.newCrew.role==="Other"&&(!this.newCrew.customRole||this.newCrew.customRole.trim()==="")&&(this.formErrors.customRole='Custom role is required when "Other" is selected'),Object.keys(this.formErrors).length>0?(this.$emit("validation-error",this.formErrors),!1):!0},isValidEmail(o){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)},addCertificationEntry(){this.newCrew.certifications.push({name:"",expiryDate:"",imageFile:null,imagePreview:null,imageName:"",imageType:""})},removeCertification(o){this.newCrew.certifications.splice(o,1)},handleCertImageUpload(o,t){const r=o.target.files[0];if(!r)return;const l=this.newCrew.certifications[t];if(l.imageFile=r,l.imageName=r.name,l.imageType=r.type.includes("pdf")?"pdf":"image",l.imageType==="image"){const i=new FileReader;i.onload=s=>{l.imagePreview=s.target.result},i.readAsDataURL(r)}else l.imagePreview="pdf"},removeCertImage(o){const t=this.newCrew.certifications[o];t.imageFile=null,t.imagePreview=null,t.imageName="",t.imageType="";const r=document.getElementById("cert-image-"+o);r&&(r.value="")},formatStatus(o){return o?o.charAt(0).toUpperCase()+o.slice(1):""},getStatusClass(o){return{available:"status-available",onduty:"status-onduty",onboard:"status-onboard",unavailable:"status-unavailable",assigned:"status-assigned"}[o]||""},getCertificationClass(o){const t=this.getExpiryStatus(o);return{expired:"text-danger",expiringSoon:"text-warning",valid:"text-success"}[t]||""},getExpiryStatus(o){if(!o)return"none";const t=new Date(o),r=new Date,l=new Date;return l.setMonth(r.getMonth()+1),t<=r?"expired":t<=l?"expiringSoon":"valid"},formatLogDate(o){return o?new Date(o).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""},getLogActionClass(o){return{Embarked:"log-action-embark",Deboarded:"log-action-deboard",Assigned:"log-action-assign","Status Changed":"log-action-status"}[o]||""},getLogIcon(o){return{Embarked:"bi bi-box-arrow-in-right",Deboarded:"bi bi-box-arrow-left",Assigned:"bi bi-calendar-check","Status Changed":"bi bi-arrow-repeat"}[o]||"bi bi-circle-fill"}}},Rl={class:"crew-management"},Al={key:0,class:"wave-bg"},Pl={class:"crew-section"},Ml={class:"crew-section-header"},Il={class:"crew-subhead"},Ll={class:"header-actions"},ql={key:0,class:"personnel-summary"},zl={class:"summary-header"},Ol={class:"summary-date"},Ul={class:"summary-cards"},jl={class:"summary-card total-card"},Gl={class:"card-content"},Hl={class:"card-value"},Wl={class:"summary-card crew-card"},Ql={class:"card-content"},Jl={class:"card-value"},Yl={class:"summary-card guest-card-summary"},Zl={class:"card-content"},Kl={class:"card-value"},$l={key:0,class:"vessel-breakdown"},Xl={class:"vessel-cards"},vl={class:"vessel-name"},er={class:"vessel-stats"},tr={class:"stat-item"},or={class:"stat-value"},nr={class:"stat-item"},ir={class:"stat-value"},sr={class:"stat-item total-stat"},lr={class:"stat-value"},rr={key:1,class:"search-filter"},ar={key:2,class:"loading-state"},dr={key:3,class:"timesheet-view"},cr={class:"timesheet-header"},mr={class:"timesheet-controls"},pr={class:"timesheet-summary"},fr={class:"summary-card"},hr={class:"summary-value"},gr={class:"summary-card"},yr={class:"summary-value"},Er={class:"summary-card"},Nr={class:"summary-value"},br={key:0,class:"no-results"},Vr={key:1,class:"timesheet-table-container"},kr={class:"timesheet-table"},wr={class:"timestamp-cell"},Cr={class:"crew-name-cell"},Dr={class:"role-cell"},_r={class:"action-cell"},Sr={class:"vessel-cell"},Fr={class:"duration-cell"},ur={class:"notes-cell"},Br={key:4,class:"crew-grid"},xr={class:"crew-name"},Tr={class:"crew-role"},Rr={key:0,class:"crew-certifications"},Ar=["onClick"],Pr={key:0,class:"certification-tag text-muted"},Mr=["onClick"],Ir={key:1},Lr={class:"crew-availability"},qr={class:"crew-availability"},zr={class:"crew-availability"},Or={key:2},Ur={class:"crew-availability"},jr={class:"crew-availability"},Gr={class:"crew-availability"},Hr={class:"action-buttons"},Wr={key:0,class:"status-available crew-availability vcard"},Qr={key:1,class:"status-unavailable crew-availability vcard"},Jr=["onClick"],Yr=["onClick"],Zr=["onClick"],Kr=["onClick"],$r={class:"crew-footer"},Xr={key:0,class:"crew-log-toggle"},vr=["onClick"],ea=["onClick"],ta={key:3,class:"crew-log"},oa={class:"log-date"},na={class:"log-details"},ia={key:0},sa={key:1},la={key:0,class:"log-notes"},ra={key:5,class:"no-results"},aa={key:6,class:"add-crew-form"},da={class:"form-row"},ca={class:"form-group"},ma={key:0,class:"error-message"},pa={class:"form-group"},fa=["value"],ha={class:"form-row"},ga={class:"form-group"},ya={key:0,class:"error-message"},Ea={class:"form-row"},Na={class:"form-group"},ba={class:"form-actions"},Va={key:7,class:"add-crew-form"},ka={class:"form-row"},wa={class:"form-group"},Ca={key:0,class:"error-message"},Da={class:"form-group"},_a={key:0,class:"form-row"},Sa={class:"form-group"},Fa=["value"],ua={key:0,class:"error-message"},Ba={class:"form-row"},xa={class:"form-group"},Ta={key:0,class:"error-message"},Ra={class:"form-group"},Aa={key:0,class:"error-message"},Pa={class:"form-row"},Ma={class:"form-group"},Ia={class:"form-actions"};function La(o,t,r,l,i,s){return e.openBlock(),e.createElementBlock("div",Rl,[r.config.showWaveBackground?(e.openBlock(),e.createElementBlock("div",Al)):e.createCommentVNode("",!0),e.createElementVNode("div",Pl,[e.createElementVNode("div",Ml,[e.createElementVNode("h4",Il,e.toDisplayString(s.sectionTitle),1),e.createElementVNode("div",Ll,[s.canAddCrew?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-secondary",onClick:t[0]||(t[0]=(...n)=>s.handleToggleGuestForm&&s.handleToggleGuestForm(...n))},e.toDisplayString(i.showGuestForm?"Cancel":"+ Check-in Guest"),1)):e.createCommentVNode("",!0),s.canAddCrew?(e.openBlock(),e.createElementBlock("button",{key:1,class:"btn btn-primary",onClick:t[1]||(t[1]=(...n)=>s.handleToggleAddForm&&s.handleToggleAddForm(...n))},e.toDisplayString(i.showAddForm?"Cancel":"+ Add Crew Member"),1)):e.createCommentVNode("",!0)])]),!i.showAddForm&&!i.showGuestForm&&!i.showTimesheet?(e.openBlock(),e.createElementBlock("div",ql,[e.createElementVNode("div",zl,[t[29]||(t[29]=e.createElementVNode("h3",null,[e.createElementVNode("i",{class:"bi bi-people-fill"}),e.createTextVNode(" Personnel Onboard Summary")],-1)),e.createElementVNode("div",Ol,e.toDisplayString(s.currentDate),1)]),e.createElementVNode("div",Ul,[e.createElementVNode("div",jl,[t[31]||(t[31]=e.createElementVNode("div",{class:"card-icon"},[e.createElementVNode("i",{class:"bi bi-people"})],-1)),e.createElementVNode("div",Gl,[e.createElementVNode("div",Hl,e.toDisplayString(s.totalOnboard),1),t[30]||(t[30]=e.createElementVNode("div",{class:"card-label"},"Total Onboard",-1))])]),e.createElementVNode("div",Wl,[t[33]||(t[33]=e.createElementVNode("div",{class:"card-icon"},[e.createElementVNode("i",{class:"bi bi-person-badge"})],-1)),e.createElementVNode("div",Ql,[e.createElementVNode("div",Jl,e.toDisplayString(s.crewOnboard),1),t[32]||(t[32]=e.createElementVNode("div",{class:"card-label"},"Crew Onboard",-1))])]),e.createElementVNode("div",Yl,[t[35]||(t[35]=e.createElementVNode("div",{class:"card-icon"},[e.createElementVNode("i",{class:"bi bi-person-check"})],-1)),e.createElementVNode("div",Zl,[e.createElementVNode("div",Kl,e.toDisplayString(s.guestsOnboard),1),t[34]||(t[34]=e.createElementVNode("div",{class:"card-label"},"Guests Onboard",-1))])])]),Object.keys(s.personnelByVessel).length>0?(e.openBlock(),e.createElementBlock("div",$l,[t[39]||(t[39]=e.createElementVNode("h4",null,"Breakdown by Vessel",-1)),e.createElementVNode("div",Xl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.personnelByVessel,(n,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,class:"vessel-card"},[e.createElementVNode("div",vl,e.toDisplayString(a),1),e.createElementVNode("div",er,[e.createElementVNode("div",tr,[t[36]||(t[36]=e.createElementVNode("span",{class:"stat-label"},"Crew:",-1)),e.createElementVNode("span",or,e.toDisplayString(n.crew),1)]),e.createElementVNode("div",nr,[t[37]||(t[37]=e.createElementVNode("span",{class:"stat-label"},"Guests:",-1)),e.createElementVNode("span",ir,e.toDisplayString(n.guests),1)]),e.createElementVNode("div",sr,[t[38]||(t[38]=e.createElementVNode("span",{class:"stat-label"},"Total:",-1)),e.createElementVNode("span",lr,e.toDisplayString(n.total),1)])])]))),128))])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!i.showAddForm&&!i.showGuestForm?(e.openBlock(),e.createElementBlock("div",rr,[e.withDirectives(e.createElementVNode("input",{type:"text",placeholder:"Search crew by name or role...","onUpdate:modelValue":t[2]||(t[2]=n=>i.searchQuery=n),onInput:t[3]||(t[3]=(...n)=>s.handleSearch&&s.handleSearch(...n))},null,544),[[e.vModelText,i.searchQuery]]),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[4]||(t[4]=n=>i.filterStatus=n),onChange:t[5]||(t[5]=(...n)=>s.handleFilter&&s.handleFilter(...n))},t[40]||(t[40]=[e.createStaticVNode('<option value="all">All Statuses</option><option value="available">Available</option><option value="onduty">On Duty</option><option value="onboard">On Board</option><option value="assigned">Assigned</option><option value="unavailable">Unavailable</option>',6)]),544),[[e.vModelSelect,i.filterStatus]]),e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[6]||(t[6]=n=>i.showTimesheet=!i.showTimesheet)},[e.createElementVNode("i",{class:e.normalizeClass(i.showTimesheet?"bi bi-grid-3x3-gap":"bi bi-table")},null,2),e.createTextVNode(" "+e.toDisplayString(i.showTimesheet?"Show Crew Cards":"Show Timesheet"),1)])])):e.createCommentVNode("",!0),r.loading&&!i.showAddForm&&!i.showGuestForm?(e.openBlock(),e.createElementBlock("div",ar,t[41]||(t[41]=[e.createElementVNode("div",{class:"spinner-border text-primary",role:"status"},[e.createElementVNode("span",{class:"visually-hidden"},"Loading crew...")],-1),e.createElementVNode("p",null,"Loading crew members...",-1)]))):i.showTimesheet&&!i.showAddForm&&!i.showGuestForm?(e.openBlock(),e.createElementBlock("div",dr,[e.createElementVNode("div",cr,[t[43]||(t[43]=e.createElementVNode("h3",null,[e.createElementVNode("i",{class:"bi bi-table"}),e.createTextVNode(" Crew Activity Timesheet")],-1)),e.createElementVNode("div",mr,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[7]||(t[7]=n=>i.timesheetFilter=n),onChange:t[8]||(t[8]=(...n)=>s.filterTimesheet&&s.filterTimesheet(...n))},t[42]||(t[42]=[e.createStaticVNode('<option value="all">All Activities</option><option value="Embarked">Embarked Only</option><option value="Deboarded">Deboarded Only</option><option value="Assigned">Assigned Only</option><option value="Status Changed">Status Changes Only</option>',5)]),544),[[e.vModelSelect,i.timesheetFilter]]),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":t[9]||(t[9]=n=>i.timesheetSearch=n),placeholder:"Search timesheet...",class:"timesheet-search"},null,512),[[e.vModelText,i.timesheetSearch]])])]),e.createElementVNode("div",pr,[e.createElementVNode("div",fr,[t[44]||(t[44]=e.createElementVNode("span",{class:"summary-label"},"Total Entries:",-1)),e.createElementVNode("span",hr,e.toDisplayString(s.filteredTimesheetEntries.length),1)]),e.createElementVNode("div",gr,[t[45]||(t[45]=e.createElementVNode("span",{class:"summary-label"},"Crew Members:",-1)),e.createElementVNode("span",yr,e.toDisplayString(s.uniqueCrewCount),1)]),e.createElementVNode("div",Er,[t[46]||(t[46]=e.createElementVNode("span",{class:"summary-label"},"Date Range:",-1)),e.createElementVNode("span",Nr,e.toDisplayString(s.timesheetDateRange),1)])]),s.filteredTimesheetEntries.length===0?(e.openBlock(),e.createElementBlock("div",br," No timesheet entries found. ")):(e.openBlock(),e.createElementBlock("div",Vr,[e.createElementVNode("table",kr,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",{onClick:t[10]||(t[10]=n=>s.sortTimesheet("timestamp"))},t[47]||(t[47]=[e.createTextVNode(" Date/Time ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),e.createElementVNode("th",{onClick:t[11]||(t[11]=n=>s.sortTimesheet("crewName"))},t[48]||(t[48]=[e.createTextVNode(" Crew Member ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),e.createElementVNode("th",{onClick:t[12]||(t[12]=n=>s.sortTimesheet("role"))},t[49]||(t[49]=[e.createTextVNode(" Role ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),e.createElementVNode("th",{onClick:t[13]||(t[13]=n=>s.sortTimesheet("action"))},t[50]||(t[50]=[e.createTextVNode(" Action ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),t[51]||(t[51]=e.createElementVNode("th",null,"Vessel",-1)),t[52]||(t[52]=e.createElementVNode("th",null,"Duration",-1)),t[53]||(t[53]=e.createElementVNode("th",null,"Notes",-1))])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.filteredTimesheetEntries,n=>(e.openBlock(),e.createElementBlock("tr",{key:n.uniqueId,class:e.normalizeClass(s.getTimesheetRowClass(n.action))},[e.createElementVNode("td",wr,e.toDisplayString(s.formatLogDate(n.timestamp)),1),e.createElementVNode("td",Cr,[e.createElementVNode("strong",null,e.toDisplayString(n.crewName),1)]),e.createElementVNode("td",Dr,e.toDisplayString(n.role),1),e.createElementVNode("td",_r,[e.createElementVNode("span",{class:e.normalizeClass(["action-badge",s.getLogActionClass(n.action)])},[e.createElementVNode("i",{class:e.normalizeClass(s.getLogIcon(n.action))},null,2),e.createTextVNode(" "+e.toDisplayString(n.action),1)],2)]),e.createElementVNode("td",Sr,e.toDisplayString(n.vessel||"N/A"),1),e.createElementVNode("td",Fr,e.toDisplayString(n.duration?n.duration+" days":"N/A"),1),e.createElementVNode("td",ur,e.toDisplayString(n.notes||"-"),1)],2))),128))])])]))])):s.filteredCrew.length>0&&!i.showAddForm&&!i.showGuestForm?(e.openBlock(),e.createElementBlock("div",Br,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.filteredCrew,n=>(e.openBlock(),e.createElementBlock("div",{key:n.id,class:e.normalizeClass(["crew-card",{unavailable:n.status==="unavailable","guest-card":n.role==="guest"}])},[e.createElementVNode("div",{class:e.normalizeClass(["crew-status-badge",s.getStatusClass(n.status)])},e.toDisplayString(s.formatStatus(n.status)),3),e.createElementVNode("div",xr,e.toDisplayString(n.name),1),e.createElementVNode("div",Tr,e.toDisplayString(n.role==="guest"?"Guest":n.role),1),n.role!=="guest"?(e.openBlock(),e.createElementBlock("div",Rr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.getApprovedCertifications(n),a=>(e.openBlock(),e.createElementBlock("div",{key:a.name,class:e.normalizeClass(["certification-tag",s.getCertificationClass(a.expiryDate)]),onClick:c=>s.handleViewCertification(a,n)},e.toDisplayString(a.name),11,Ar))),128)),s.getPendingCertificationsCount(n)>0?(e.openBlock(),e.createElementBlock("div",Pr,[t[54]||(t[54]=e.createElementVNode("i",{class:"bi bi-clock-history"},null,-1)),e.createTextVNode(" "+e.toDisplayString(s.getPendingCertificationsCount(n))+" pending ",1)])):e.createCommentVNode("",!0),s.canEditCrew?(e.openBlock(),e.createElementBlock("i",{key:1,class:"bi bi-patch-plus-fill icon",onClick:a=>s.handleAddCertification(n)},null,8,Mr)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),n.role==="guest"?(e.openBlock(),e.createElementBlock("div",Ir,[e.createElementVNode("div",Lr,[t[55]||(t[55]=e.createElementVNode("strong",null,"Arrival Date:",-1)),e.createTextVNode(" "+e.toDisplayString(n.nextShift||"Not Recorded"),1)]),e.createElementVNode("div",qr,[t[56]||(t[56]=e.createElementVNode("strong",null,"Expected Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(n.onBoard||"Not Specified"),1)]),e.createElementVNode("div",zr,[t[57]||(t[57]=e.createElementVNode("strong",null,"Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(s.getGuestDaysOnboard(n)),1)])])):(e.openBlock(),e.createElementBlock("div",Or,[e.createElementVNode("div",Ur,[t[58]||(t[58]=e.createElementVNode("strong",null,"Embarkation Date:",-1)),e.createTextVNode(" "+e.toDisplayString(s.getEmbarkationDate(n)),1)]),e.createElementVNode("div",jr,[t[59]||(t[59]=e.createElementVNode("strong",null,"Expected Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(n.onBoard||"Not Scheduled"),1)]),e.createElementVNode("div",Gr,[t[60]||(t[60]=e.createElementVNode("strong",null,"Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(s.getDaysOnboard(n)),1)])])),e.createElementVNode("div",Hr,[n.vessel?(e.openBlock(),e.createElementBlock("div",Wr," Vessel: "+e.toDisplayString(n.vessel),1)):(e.openBlock(),e.createElementBlock("div",Qr," Vessel: Unassigned ")),n.role==="guest"&&n.status==="onboard"?(e.openBlock(),e.createElementBlock("button",{key:2,class:"btn btn-warning",onClick:a=>s.handleCheckoutGuest(n)}," Check Out ",8,Jr)):e.createCommentVNode("",!0),n.role!=="guest"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[s.canAssignShift&&n.status==="available"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-primary",onClick:a=>s.handleAssignShift(n)}," Assign Shift ",8,Yr)):e.createCommentVNode("",!0),s.canDeboardCrew&&n.status==="onduty"?(e.openBlock(),e.createElementBlock("button",{key:1,class:"btn btn-success",onClick:a=>s.handleCheckinCrew(n)}," Check In ",8,Zr)):e.createCommentVNode("",!0),s.canDeboardCrew&&n.status==="onboard"?(e.openBlock(),e.createElementBlock("button",{key:2,class:"btn btn-warning",onClick:a=>s.handleDeboardCrew(n)}," Deboard ",8,Kr)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)]),e.createElementVNode("div",$r,[n.log&&n.log.length>0?(e.openBlock(),e.createElementBlock("div",Xr,[e.createElementVNode("button",{class:"btn btn-link btn-sm log-toggle-btn",onClick:a=>s.toggleCrewLog(n.id)},[t[61]||(t[61]=e.createElementVNode("i",{class:"bi bi-clock-history"},null,-1)),e.createTextVNode(" View Log ("+e.toDisplayString(n.log.length)+") ",1)],8,vr)])):e.createCommentVNode("",!0),s.canDeleteCrew?(e.openBlock(),e.createElementBlock("i",{key:1,class:"bi bi-trash icon delete-icon",onClick:a=>s.handleDeleteCrew(n)},null,8,ea)):e.createCommentVNode("",!0)]),i.expandedLogs.includes(n.id)?(e.openBlock(),e.createElementBlock("div",ta,[t[62]||(t[62]=e.createElementVNode("h4",null,"Crew Activity Log",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.log,(a,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"log-entry"},[e.createElementVNode("div",oa,e.toDisplayString(s.formatLogDate(a.timestamp)),1),e.createElementVNode("div",{class:e.normalizeClass(["log-action",s.getLogActionClass(a.action)])},[e.createElementVNode("i",{class:e.normalizeClass(s.getLogIcon(a.action))},null,2),e.createTextVNode(" "+e.toDisplayString(a.action),1)],2),e.createElementVNode("div",na,[a.vessel?(e.openBlock(),e.createElementBlock("span",ia,"Vessel: "+e.toDisplayString(a.vessel),1)):e.createCommentVNode("",!0),a.duration?(e.openBlock(),e.createElementBlock("span",sa," | Duration: "+e.toDisplayString(a.duration)+" days",1)):e.createCommentVNode("",!0)]),a.notes?(e.openBlock(),e.createElementBlock("div",la,e.toDisplayString(a.notes),1)):e.createCommentVNode("",!0)]))),128))])):e.createCommentVNode("",!0)],2))),128))])):!r.loading&&!i.showTimesheet&&!i.showAddForm&&!i.showGuestForm?(e.openBlock(),e.createElementBlock("div",ra,e.toDisplayString(r.crew.length===0?"No crew members found.":"No crew members found matching your search criteria."),1)):e.createCommentVNode("",!0),i.showAddForm?(e.openBlock(),e.createElementBlock("div",aa,[t[68]||(t[68]=e.createElementVNode("h2",null,"Add New Crew Member",-1)),e.createElementVNode("div",da,[e.createElementVNode("div",ca,[t[63]||(t[63]=e.createElementVNode("label",{for:"crew-name"},"Full Name *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"crew-name","onUpdate:modelValue":t[14]||(t[14]=n=>i.newCrew.name=n),class:e.normalizeClass({error:i.formErrors.name})},null,2),[[e.vModelText,i.newCrew.name]]),i.formErrors.name?(e.openBlock(),e.createElementBlock("div",ma,e.toDisplayString(i.formErrors.name),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",pa,[t[65]||(t[65]=e.createElementVNode("label",{for:"crew-role"},"Role/Position *",-1)),e.withDirectives(e.createElementVNode("select",{id:"crew-role","onUpdate:modelValue":t[15]||(t[15]=n=>i.newCrew.role=n)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.availableRoles,n=>(e.openBlock(),e.createElementBlock("option",{key:n,value:n},e.toDisplayString(n),9,fa))),128)),t[64]||(t[64]=e.createElementVNode("option",{value:"Other"},"Other",-1))],512),[[e.vModelSelect,i.newCrew.role]]),i.newCrew.role==="Other"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,type:"text",placeholder:"Enter custom role","onUpdate:modelValue":t[16]||(t[16]=n=>i.newCrew.customRole=n),style:{"margin-top":"8px"}},null,512)),[[e.vModelText,i.newCrew.customRole]]):e.createCommentVNode("",!0)])]),e.createElementVNode("div",ha,[e.createElementVNode("div",ga,[t[66]||(t[66]=e.createElementVNode("label",{for:"crew-email"},"Email Address *",-1)),e.withDirectives(e.createElementVNode("input",{type:"email",id:"crew-email","onUpdate:modelValue":t[17]||(t[17]=n=>i.newCrew.email=n),class:e.normalizeClass({error:i.formErrors.email})},null,2),[[e.vModelText,i.newCrew.email]]),i.formErrors.email?(e.openBlock(),e.createElementBlock("div",ya,e.toDisplayString(i.formErrors.email),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Ea,[e.createElementVNode("div",Na,[t[67]||(t[67]=e.createElementVNode("label",{for:"crew-notes"},"Notes",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"crew-notes",rows:"3","onUpdate:modelValue":t[18]||(t[18]=n=>i.newCrew.notes=n)},null,512),[[e.vModelText,i.newCrew.notes]])])]),e.createElementVNode("div",ba,[e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[19]||(t[19]=(...n)=>s.handleCancelForm&&s.handleCancelForm(...n))},"Cancel"),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[20]||(t[20]=(...n)=>s.handleAddCrewMember&&s.handleAddCrewMember(...n))},"Add Crew Member")])])):e.createCommentVNode("",!0),i.showGuestForm?(e.openBlock(),e.createElementBlock("div",Va,[t[76]||(t[76]=e.createElementVNode("h2",null,"Check-in Guest",-1)),e.createElementVNode("div",ka,[e.createElementVNode("div",wa,[t[69]||(t[69]=e.createElementVNode("label",{for:"guest-name"},"Full Name *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"guest-name","onUpdate:modelValue":t[21]||(t[21]=n=>i.newGuest.name=n),class:e.normalizeClass({error:i.guestFormErrors.name})},null,2),[[e.vModelText,i.newGuest.name]]),i.guestFormErrors.name?(e.openBlock(),e.createElementBlock("div",Ca,e.toDisplayString(i.guestFormErrors.name),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Da,[t[70]||(t[70]=e.createElementVNode("label",{for:"guest-email"},"Email Address",-1)),e.withDirectives(e.createElementVNode("input",{type:"email",id:"guest-email","onUpdate:modelValue":t[22]||(t[22]=n=>i.newGuest.email=n)},null,512),[[e.vModelText,i.newGuest.email]])])]),r.vesselName?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_a,[e.createElementVNode("div",Sa,[t[72]||(t[72]=e.createElementVNode("label",{for:"guest-vessel"},"Vessel *",-1)),e.withDirectives(e.createElementVNode("select",{id:"guest-vessel","onUpdate:modelValue":t[23]||(t[23]=n=>i.newGuest.vessel=n),class:e.normalizeClass({error:i.guestFormErrors.vessel})},[t[71]||(t[71]=e.createElementVNode("option",{value:""},"Select a vessel",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.availableVessels,n=>(e.openBlock(),e.createElementBlock("option",{key:n,value:n},e.toDisplayString(n),9,Fa))),128))],2),[[e.vModelSelect,i.newGuest.vessel]]),i.guestFormErrors.vessel?(e.openBlock(),e.createElementBlock("div",ua,e.toDisplayString(i.guestFormErrors.vessel),1)):e.createCommentVNode("",!0)])])),e.createElementVNode("div",Ba,[e.createElementVNode("div",xa,[t[73]||(t[73]=e.createElementVNode("label",{for:"guest-arrival"},"Arrival Date *",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",id:"guest-arrival","onUpdate:modelValue":t[24]||(t[24]=n=>i.newGuest.arrivalDate=n),class:e.normalizeClass({error:i.guestFormErrors.arrivalDate})},null,2),[[e.vModelText,i.newGuest.arrivalDate]]),i.guestFormErrors.arrivalDate?(e.openBlock(),e.createElementBlock("div",Ta,e.toDisplayString(i.guestFormErrors.arrivalDate),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Ra,[t[74]||(t[74]=e.createElementVNode("label",{for:"guest-expected-days"},"Expected Days Onboard *",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",id:"guest-expected-days","onUpdate:modelValue":t[25]||(t[25]=n=>i.newGuest.expectedDays=n),min:"1",class:e.normalizeClass({error:i.guestFormErrors.expectedDays})},null,2),[[e.vModelText,i.newGuest.expectedDays]]),i.guestFormErrors.expectedDays?(e.openBlock(),e.createElementBlock("div",Aa,e.toDisplayString(i.guestFormErrors.expectedDays),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Pa,[e.createElementVNode("div",Ma,[t[75]||(t[75]=e.createElementVNode("label",{for:"guest-notes"},"Notes",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"guest-notes",rows:"3","onUpdate:modelValue":t[26]||(t[26]=n=>i.newGuest.notes=n),placeholder:"Purpose of visit, company affiliation, etc."},null,512),[[e.vModelText,i.newGuest.notes]])])]),e.createElementVNode("div",Ia,[e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[27]||(t[27]=(...n)=>s.handleCancelGuestForm&&s.handleCancelGuestForm(...n))},"Cancel"),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[28]||(t[28]=(...n)=>s.handleCheckinGuest&&s.handleCheckinGuest(...n))},"Check-in Guest")])])):e.createCommentVNode("",!0)])])}const q=F(Tl,[["render",La]]),wm="",qa={name:"RequisitionSystem",props:{userProfile:{type:Object,required:!0},userRole:{type:String,required:!0},requisitions:{type:Array,default:()=>[]},vessels:{type:Array,default:()=>[]}},emits:["submit-requisition","submit-info-response","approve-requisition","decline-requisition","info-requisition","create-po","open-po","finish-po","accept-delivery"],data(){return{activeTab:"workflow",isPrinting:!1,infoResponse:"",isSubmitting:!1,tabs:[{name:"new-requisition",label:"New Requisition",roles:["requisitor"]},{name:"my-requisitions",label:"My Requisitions",roles:["requisitor"]},{name:"all-requisitions",label:"All Requisitions",roles:["requisitor","supervisor","captain","owner","purchaser"]},{name:"approvals",label:"Pending Approvals",roles:["owner","supervisor"]},{name:"purchasing",label:"Purchasing Queue",roles:["purchaser"]},{name:"receiving",label:"Receiving",roles:["requisitor"]},{name:"workflow",label:"Workflow Guide",roles:["requisitor","supervisor","owner","purchaser","captain"]}],form:{requestor:"",department:"",project:"",neededDate:"",justification:"",items:[]},poDetails:{editing:!1,items:[]},vendorInfo:{},justificationText:"",currentItemIndex:null,showJustificationModal:!1,requisitionFields:[{label:"Requestor",value:o=>o.requestor},{label:"Department",value:o=>o.department},{label:"Project",value:o=>o.project||"N/A"},{label:"Submitted",value:o=>o.submittedDate},{label:"Items",value:o=>{var t;return`${((t=o.items)==null?void 0:t.length)||0} item(s)`}}],requisitionFieldsMap:{approved:[{label:"Approved By",value:o=>o.approvedBy}],declined:[{label:"Declined By",value:o=>o.declinedBy},{label:"Rejection Reason",value:o=>o.rejectionReason}],"info-requested":[{label:"Info Requester",value:o=>o.infoRequestedBy},{label:"Requested Info",value:o=>o.requestedInfo}]},departments:["Marine Operations","Engineering","Maintenance","Safety & Compliance","Logistics","Administration","Engine Room"],priorities:["Urgent - Same Day","High - Within 3 Days","Normal - Within 1 Week","Low - Within 2 Weeks"],units:["Pieces","Kilograms","Liters","Meters","Sets","Boxes"]}},computed:{today(){return new Date().toISOString().split("T")[0]},visibleTabs(){return this.tabs.filter(o=>o.roles.includes(this.userRole))},subTotal(){return(this.poDetails.items||[]).reduce((o,t)=>{const r=t.unitPrice||t.cost||0;return o+r*(t.qty||0)},0)},grandTotal(){return this.subTotal+this.calculateTax()+parseFloat(this.getOptional(this.vendorInfo.shipping))},reviewRequisitions(){return(this.requisitions||[]).filter(o=>o.status==="under-review")},poRequisitions(){return(this.requisitions||[]).filter(o=>o.status==="approved")},awaitingDelivery(){return(this.requisitions||[]).filter(o=>o.status==="po-created")},currentItem(){return this.currentItemIndex!==null?this.poDetails.items[this.currentItemIndex]:null},myRequisitions(){var t,r;const o=((t=this.userProfile)==null?void 0:t.id)||((r=this.userProfile)==null?void 0:r.profile_id);return(this.requisitions||[]).filter(l=>l.profile_id==o)}},methods:{setActiveTab(o){this.activeTab=o},formatDate(o){return o?new Date(o).toLocaleDateString():"N/A"},calculateTax(){var t;const o=parseFloat(this.vendorInfo.tax||((t=this.poDetails.vendorInfo)==null?void 0:t.tax)||0);return this.subTotal*o/100},getOptional(o){return typeof o=="number"?o.toFixed(2):(parseFloat(o)||0).toFixed(2)},getRequisitionFields(o){const t=this.requisitionFieldsMap[o.status]||[];return[...this.requisitionFields||[],...t]},addItem(){this.form.items.push({id:"",desc:"",qty:1,unit:"Pieces",cost:0})},removeItem(o){this.form.items.splice(o,1)},startEdit(o){this.poDetails.items[o].editing=!0,this.poDetails.items[o].tempPrice=this.poDetails.items[o].unitPrice||this.poDetails.items[o].cost},cancelEdit(o){this.poDetails.items[o].editing=!1,this.poDetails.items[o].tempPrice=this.poDetails.items[o].unitPrice||this.poDetails.items[o].cost},savePrice(o){const t=this.poDetails.items[o];t.tempPrice!==t.cost?(this.currentItemIndex=o,this.showJustificationModal=!0):(t.unitPrice=t.tempPrice,t.editing=!1)},confirmPriceChange(){if(!this.justificationText.trim()){alert("Please provide a justification for the price change.");return}const o=this.poDetails.items[this.currentItemIndex];o.unitPrice=o.tempPrice,o.cost=o.tempPrice,o.justification=this.justificationText.trim(),o.editing=!1,this.closeJustificationModal()},closeJustificationModal(){this.showJustificationModal=!1,this.currentItemIndex=null,this.justificationText=""},handleSubmitRequisition(){if(this.form.items.length===0){alert("Please add at least one item to the requisition.");return}this.isSubmitting=!0;const o=this.collectFormData("under-review");this.$emit("submit-requisition",o),setTimeout(()=>{this.resetForm(),this.isSubmitting=!1},1e3)},handleSubmitInfoResponse(o){if(!this.infoResponse||this.infoResponse.trim()===""){alert("Please enter a response before submitting.");return}this.$emit("submit-info-response",{req:o,response:this.infoResponse}),this.infoResponse=""},handleApproveRequisition(o){this.$emit("approve-requisition",o)},handleDeclineRequisition(o){this.$emit("decline-requisition",o)},handleInfoRequisition(o){this.$emit("info-requisition",o)},handleCreatePO(o){this.$emit("create-po",o)},handleOpenPO(o){this.$emit("open-po",o)},handleFinishPO(o){this.$emit("finish-po",o)},handleAcceptDelivery(o){this.$emit("accept-delivery",o)},collectFormData(o){var t,r,l;return{id:"REQ-"+Date.now(),requestor:((t=this.userProfile)==null?void 0:t.full_name)||"Unknown",department:this.form.department,project:this.form.project,neededDate:this.form.neededDate,justification:this.form.justification,items:this.form.items.map(i=>({...i})),status:o,submittedDate:new Date().toLocaleDateString(),profile_id:((r=this.userProfile)==null?void 0:r.id)||((l=this.userProfile)==null?void 0:l.profile_id)}},resetForm(){this.form={requestor:"",department:"",project:"",neededDate:"",justification:"",items:[]},this.addItem()},updatePODetails(o){this.poDetails={...o},this.getNumber();for(let t of this.poDetails.items||[])t.tempPrice=t.cost||0,t.unitPrice=t.unitPrice||t.cost||0,t.subTotal=t.unitPrice*(t.qty||0)},updateVendorInfo(o){this.vendorInfo={...o}},setPrintingMode(o){this.isPrinting=o},getNumber(){return(this.poDetails.items||[]).map((o,t)=>o.itemNumber=t+1)}},created(){this.addItem()}},za={class:"s-container container"},Oa={class:"nav-tabs"},Ua=["onClick"],ja={key:0,class:"tab-content active"},Ga={class:"form-grid"},Ha={class:"form-group"},Wa=["value"],Qa={class:"form-group"},Ja=["value"],Ya={class:"form-group"},Za=["value"],Ka={class:"form-group"},$a=["min"],Xa={class:"form-group"},va={class:"items-section"},ed={class:"items-header"},td={class:"form-group"},od=["onUpdate:modelValue"],nd={class:"form-group"},id=["onUpdate:modelValue"],sd={class:"form-group"},ld=["onUpdate:modelValue"],rd={class:"form-group"},ad=["onUpdate:modelValue"],dd=["value"],cd={class:"form-group"},md=["onUpdate:modelValue"],pd=["onClick"],fd={class:"action-buttons"},hd=["disabled"],gd={key:1,class:"tab-content active"},yd={class:"requisition-list"},Ed={class:"requisition-header"},Nd={class:"requisition-id"},bd={class:"requisition-details"},Vd={class:"detail-label"},kd={class:"detail-value"},wd={key:0,class:"form-group comments-section"},Cd=["onClick"],Dd={key:2,class:"tab-content active"},_d={class:"requisition-list"},Sd={class:"requisition-header"},Fd={class:"requisition-id"},ud={class:"requisition-details"},Bd={class:"detail-label"},xd={class:"detail-value"},Td={key:0,class:"form-group comments-section"},Rd=["onClick"],Ad={key:3,class:"tab-content active"},Pd={class:"requisition-list",id:"approvalsQueue"},Md={class:"requisition-header"},Id={class:"requisition-id"},Ld={class:"requisition-details"},qd={class:"detail-label"},zd={class:"detail-value"},Od={class:"detail-item"},Ud={class:"detail-value"},jd={class:"detail-item"},Gd={class:"item-list"},Hd=["onClick"],Wd=["onClick"],Qd=["onClick"],Jd={key:4,class:"tab-content active"},Yd={class:"requisition-list",id:"purchasingQueue"},Zd={class:"requisition-header"},Kd={class:"requisition-id"},$d={class:"requisition-details"},Xd={class:"detail-label"},vd={class:"detail-value"},ec={class:"detail-item"},tc={class:"detail-value"},oc={class:"detail-item"},nc={class:"item-list"},ic=["onClick"],sc={key:5,class:"tab-content active"},lc={class:"requisition-list",id:"receivingQueue"},rc={class:"requisition-header"},ac={class:"requisition-id"},dc={class:"requisition-details"},cc={class:"detail-label"},mc={class:"detail-value"},pc={class:"detail-item"},fc={class:"detail-value"},hc={class:"detail-item"},gc={class:"item-list"},yc=["onClick"],Ec={key:6,class:"tab-content active"},Nc={class:"po-content",id:"po-content"},bc={class:"po-header"},Vc={class:"company-info"},kc={class:"info-row"},wc={class:"info-value"},Cc={class:"info-row"},Dc={class:"info-value"},_c={class:"info-row"},Sc={class:"info-value"},Fc={class:"info-row"},uc={class:"info-label"},Bc={class:"info-row"},xc={class:"info-value"},Tc={class:"company-info"},Rc={class:"info-row"},Ac={class:"info-value"},Pc={class:"info-row"},Mc={class:"info-value"},Ic={class:"info-row"},Lc={class:"info-value"},qc={class:"info-row"},zc={class:"info-value"},Oc={class:"info-row"},Uc={class:"info-value"},jc={class:"items-section"},Gc={class:"items-table"},Hc={key:0},Wc={key:0},Qc={key:0,class:"price-change-indicator"},Jc=["onUpdate:modelValue"],Yc={key:0},Zc=["onClick"],Kc={key:1},$c=["onClick"],Xc=["onClick"],vc={key:0,class:"justification-note"},em={class:"totals"},tm={class:"total-row"},om={class:"total-row"},nm={class:"total-row"},im={class:"total-row grand-total"},sm={class:"modal-content"},lm={style:{"margin-bottom":"15px",color:"#666"}},rm={class:"modal-buttons"},am=["disabled"],dm={key:7,class:"tab-content active"};function cm(o,t,r,l,i,s){var n,a,c,y,w,N,D,_,C,p,h,b,k;return e.openBlock(),e.createElementBlock("div",za,[t[60]||(t[60]=e.createElementVNode("div",{class:"header"},[e.createElementVNode("h1",null,"OceanHelm Requisition System"),e.createElementVNode("p",null,"Streamlined Material Request & Ordering Process")],-1)),e.createElementVNode("div",Oa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.visibleTabs,d=>(e.openBlock(),e.createElementBlock("button",{key:d.name,class:e.normalizeClass(["nav-tab",{active:i.activeTab===d.name}]),onClick:m=>s.setActiveTab(d.name)},e.toDisplayString(d.label),11,Ua))),128))]),i.activeTab==="new-requisition"?(e.openBlock(),e.createElementBlock("div",ja,[e.createElementVNode("form",{onSubmit:t[5]||(t[5]=e.withModifiers((...d)=>s.handleSubmitRequisition&&s.handleSubmitRequisition(...d),["prevent"]))},[e.createElementVNode("div",Ga,[e.createElementVNode("div",Ha,[t[12]||(t[12]=e.createElementVNode("label",null,"Requestor Name *",-1)),e.createElementVNode("input",{type:"text",value:(n=r.userProfile)==null?void 0:n.full_name,readonly:"",required:"",class:"form-control"},null,8,Wa)]),e.createElementVNode("div",Qa,[t[14]||(t[14]=e.createElementVNode("label",null,"Department *",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[0]||(t[0]=d=>i.form.department=d),required:""},[t[13]||(t[13]=e.createElementVNode("option",{value:""},"Select Department",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.departments,d=>(e.openBlock(),e.createElementBlock("option",{key:d,value:d},e.toDisplayString(d),9,Ja))),128))],512),[[e.vModelSelect,i.form.department]])]),e.createElementVNode("div",Ya,[t[16]||(t[16]=e.createElementVNode("label",null,"Vessel *",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[1]||(t[1]=d=>i.form.project=d),class:"form-control",required:""},[t[15]||(t[15]=e.createElementVNode("option",{disabled:"",value:""},"Select a vessel",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.vessels,d=>(e.openBlock(),e.createElementBlock("option",{key:d.id,value:d.name},e.toDisplayString(d.name),9,Za))),128))],512),[[e.vModelSelect,i.form.project]])]),e.createElementVNode("div",Ka,[t[17]||(t[17]=e.createElementVNode("label",null,"Date Needed *",-1)),e.withDirectives(e.createElementVNode("input",{type:"date","onUpdate:modelValue":t[2]||(t[2]=d=>i.form.neededDate=d),min:s.today,required:""},null,8,$a),[[e.vModelText,i.form.neededDate]])])]),e.createElementVNode("div",Xa,[t[18]||(t[18]=e.createElementVNode("label",null,"Business Justification *",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":t[3]||(t[3]=d=>i.form.justification=d),placeholder:"Explain why these materials are needed...",required:""},null,512),[[e.vModelText,i.form.justification]])]),e.createElementVNode("div",va,[e.createElementVNode("div",ed,[t[19]||(t[19]=e.createElementVNode("h3",null,"Requested Items",-1)),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:t[4]||(t[4]=(...d)=>s.addItem&&s.addItem(...d))},"+ Add Item")]),e.createElementVNode("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.form.items,(d,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:"item-row"},[e.createElementVNode("div",td,[t[20]||(t[20]=e.createElementVNode("label",null,"Item Code *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":g=>d.id=g,required:""},null,8,od),[[e.vModelText,d.id]])]),e.createElementVNode("div",nd,[t[21]||(t[21]=e.createElementVNode("label",null,"Item Description *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":g=>d.desc=g,required:""},null,8,id),[[e.vModelText,d.desc]])]),e.createElementVNode("div",sd,[t[22]||(t[22]=e.createElementVNode("label",null,"Quantity *",-1)),e.withDirectives(e.createElementVNode("input",{type:"number","onUpdate:modelValue":g=>d.qty=g,min:"1",required:""},null,8,ld),[[e.vModelText,d.qty,void 0,{number:!0}]])]),e.createElementVNode("div",rd,[t[23]||(t[23]=e.createElementVNode("label",null,"Unit *",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g=>d.unit=g,required:""},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.units,g=>(e.openBlock(),e.createElementBlock("option",{key:g,value:g},e.toDisplayString(g),9,dd))),128))],8,ad),[[e.vModelSelect,d.unit]])]),e.createElementVNode("div",cd,[t[24]||(t[24]=e.createElementVNode("label",null,"Est. Unit Cost *",-1)),e.withDirectives(e.createElementVNode("input",{type:"number","onUpdate:modelValue":g=>d.cost=g,step:"0.01",min:"0",placeholder:"0.00",required:""},null,8,md),[[e.vModelText,d.cost,void 0,{number:!0}]])]),e.createElementVNode("button",{type:"button",class:"remove-item-btn",onClick:g=>s.removeItem(m)},"Remove",8,pd)]))),128))])]),e.createElementVNode("div",fd,[e.createElementVNode("button",{type:"submit",class:"btn btn-primary-req",disabled:i.isSubmitting},e.toDisplayString(i.isSubmitting?"Submitting...":"Submit Requisition"),9,hd)])],32)])):e.createCommentVNode("",!0),i.activeTab==="all-requisitions"?(e.openBlock(),e.createElementBlock("div",gd,[e.createElementVNode("div",yd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.requisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",Ed,[e.createElementVNode("div",Nd,e.toDisplayString(d.id),1),e.createElementVNode("div",{class:e.normalizeClass(["status-badge",`status-${d.status}`])},e.toDisplayString(d.status),3)]),e.createElementVNode("div",bd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.getRequisitionFields(d),m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",Vd,e.toDisplayString(m.label),1),e.createElementVNode("div",kd,e.toDisplayString(m.value(d)),1)]))),128))]),d.status==="po-created"||d.status==="delivered"?(e.openBlock(),e.createElementBlock("div",wd,[e.createElementVNode("button",{onClick:m=>s.handleOpenPO(d.id),class:"add-item-btn comments-section"}," Print PO ",8,Cd)])):e.createCommentVNode("",!0)]))),128))])])):e.createCommentVNode("",!0),i.activeTab==="my-requisitions"?(e.openBlock(),e.createElementBlock("div",Dd,[e.createElementVNode("div",_d,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.myRequisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",Sd,[e.createElementVNode("div",Fd,e.toDisplayString(d.id),1),e.createElementVNode("div",{class:e.normalizeClass(["status-badge",`status-${d.status}`])},e.toDisplayString(d.status),3)]),e.createElementVNode("div",ud,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.getRequisitionFields(d),m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",Bd,e.toDisplayString(m.label),1),e.createElementVNode("div",xd,e.toDisplayString(m.value(d)),1)]))),128))]),d.status==="info-requested"?(e.openBlock(),e.createElementBlock("div",Td,[t[25]||(t[25]=e.createElementVNode("label",{class:"detail-label"},"Your Response",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":t[6]||(t[6]=m=>i.infoResponse=m),class:"response-textarea",placeholder:"Submit more info..."},null,512),[[e.vModelText,i.infoResponse]]),e.createElementVNode("button",{onClick:m=>s.handleSubmitInfoResponse(d),class:"add-item-btn comments-section"}," Submit Info ",8,Rd)])):e.createCommentVNode("",!0)]))),128))])])):e.createCommentVNode("",!0),i.activeTab==="approvals"?(e.openBlock(),e.createElementBlock("div",Ad,[t[28]||(t[28]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},[e.createElementVNode("h3",{style:{color:"#1e40af","margin-bottom":"15px"}},"Department Supervisor Dashboard"),e.createElementVNode("div",{style:{background:"#fef3c7",padding:"15px","border-radius":"10px","border-left":"4px solid #f59e0b"}},[e.createElementVNode("strong",null,"Role:"),e.createTextVNode(" Department Supervisor - Review requests for accuracy, necessity, and budget compliance ")])],-1)),e.createElementVNode("div",Pd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.reviewRequisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",Md,[e.createElementVNode("div",Id,e.toDisplayString(d.id),1)]),e.createElementVNode("div",Ld,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.requisitionFields,m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",qd,e.toDisplayString(m.label),1),e.createElementVNode("div",zd,e.toDisplayString(m.value(d)),1)]))),128))]),e.createElementVNode("div",Od,[t[26]||(t[26]=e.createElementVNode("div",{class:"detail-label"},"Justification",-1)),e.createElementVNode("div",Ud,e.toDisplayString(d.justification||"N/A"),1)]),e.createElementVNode("div",jd,[t[27]||(t[27]=e.createElementVNode("div",{class:"detail-label"},"Items",-1)),e.createElementVNode("ul",Gd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(m,g)=>(e.openBlock(),e.createElementBlock("li",{key:g},e.toDisplayString(m.desc)+" - "+e.toDisplayString(m.qty)+" "+e.toDisplayString(m.unit)+" @ ₦"+e.toDisplayString(m.cost.toFixed(2))+" each ",1))),128))])]),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:m=>s.handleApproveRequisition(d.id)},"Approve",8,Hd),e.createElementVNode("button",{type:"button",class:"marginbox btn-reject",onClick:m=>s.handleDeclineRequisition(d.id)},"Decline",8,Wd),e.createElementVNode("button",{type:"button",class:"marginbox btn-request",onClick:m=>s.handleInfoRequisition(d.id)},"Request Info",8,Qd)]))),128))])])):e.createCommentVNode("",!0),i.activeTab==="purchasing"?(e.openBlock(),e.createElementBlock("div",Jd,[t[31]||(t[31]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},[e.createElementVNode("h3",{style:{color:"#1e40af","margin-bottom":"15px"}},"Purchasing Department Dashboard"),e.createElementVNode("div",{style:{background:"#dbeafe",padding:"15px","border-radius":"10px","border-left":"4px solid #3b82f6"}},[e.createElementVNode("strong",null,"Role:"),e.createTextVNode(" Purchasing Team - Convert approved requisitions to Purchase Orders ")])],-1)),e.createElementVNode("div",Yd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.poRequisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",Zd,[e.createElementVNode("div",Kd,e.toDisplayString(d.id),1)]),e.createElementVNode("div",$d,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.requisitionFields,m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",Xd,e.toDisplayString(m.label),1),e.createElementVNode("div",vd,e.toDisplayString(m.value(d)),1)]))),128))]),e.createElementVNode("div",ec,[t[29]||(t[29]=e.createElementVNode("div",{class:"detail-label"},"Justification",-1)),e.createElementVNode("div",tc,e.toDisplayString(d.justification||"N/A"),1)]),e.createElementVNode("div",oc,[t[30]||(t[30]=e.createElementVNode("div",{class:"detail-label"},"Items",-1)),e.createElementVNode("ul",nc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(m,g)=>(e.openBlock(),e.createElementBlock("li",{key:g},e.toDisplayString(m.desc)+" - "+e.toDisplayString(m.qty)+" "+e.toDisplayString(m.unit)+" @ ₦"+e.toDisplayString(m.cost.toFixed(2))+" each ",1))),128))])]),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:m=>s.handleCreatePO(d.id)},"Create PO",8,ic)]))),128))])])):e.createCommentVNode("",!0),i.activeTab==="receiving"?(e.openBlock(),e.createElementBlock("div",sc,[t[34]||(t[34]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},[e.createElementVNode("h3",{style:{color:"#1e40af","margin-bottom":"15px"}},"Receiving & Inventory Dashboard"),e.createElementVNode("div",{style:{background:"#dcfce7",padding:"15px","border-radius":"10px","border-left":"4px solid #10b981"}},[e.createElementVNode("strong",null,"Role:"),e.createTextVNode(" Warehouse Team - Process incoming deliveries and update inventory ")])],-1)),e.createElementVNode("div",lc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.awaitingDelivery,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",rc,[e.createElementVNode("div",ac,e.toDisplayString(d.id),1)]),e.createElementVNode("div",dc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.requisitionFields,m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",cc,e.toDisplayString(m.label),1),e.createElementVNode("div",mc,e.toDisplayString(m.value(d)),1)]))),128))]),e.createElementVNode("div",pc,[t[32]||(t[32]=e.createElementVNode("div",{class:"detail-label"},"Justification",-1)),e.createElementVNode("div",fc,e.toDisplayString(d.justification||"N/A"),1)]),e.createElementVNode("div",hc,[t[33]||(t[33]=e.createElementVNode("div",{class:"detail-label"},"Items",-1)),e.createElementVNode("ul",gc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(m,g)=>(e.openBlock(),e.createElementBlock("li",{key:g},e.toDisplayString(m.desc)+" - "+e.toDisplayString(m.qty)+" "+e.toDisplayString(m.unit)+" @ ₦"+e.toDisplayString(m.cost.toFixed(2))+" each ",1))),128))])]),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:m=>s.handleAcceptDelivery(d.id)},"Accept Delivery",8,yc)]))),128))])])):e.createCommentVNode("",!0),i.activeTab==="po"?(e.openBlock(),e.createElementBlock("div",Ec,[e.createElementVNode("div",Nc,[e.createElementVNode("div",bc,[e.createElementVNode("div",Vc,[t[40]||(t[40]=e.createElementVNode("h3",null,"Vendor Information",-1)),e.createElementVNode("div",kc,[t[35]||(t[35]=e.createElementVNode("span",{class:"info-label"},"Company:",-1)),e.createElementVNode("span",wc,e.toDisplayString(i.vendorInfo.company||((a=i.poDetails.vendorInfo)==null?void 0:a.company)||"N/A"),1)]),e.createElementVNode("div",Cc,[t[36]||(t[36]=e.createElementVNode("span",{class:"info-label"},"Contact:",-1)),e.createElementVNode("span",Dc,e.toDisplayString(i.vendorInfo.contact||((c=i.poDetails.vendorInfo)==null?void 0:c.contact)||"N/A"),1)]),e.createElementVNode("div",_c,[t[37]||(t[37]=e.createElementVNode("span",{class:"info-label"},"Email:",-1)),e.createElementVNode("span",Sc,e.toDisplayString(i.vendorInfo.email||((y=i.poDetails.vendorInfo)==null?void 0:y.email)||"N/A"),1)]),e.createElementVNode("div",Fc,[t[38]||(t[38]=e.createElementVNode("span",{class:"info-label"},"Phone:",-1)),e.createElementVNode("span",uc,e.toDisplayString(i.vendorInfo.phone||((w=i.poDetails.vendorInfo)==null?void 0:w.phone)||"N/A"),1)]),e.createElementVNode("div",Bc,[t[39]||(t[39]=e.createElementVNode("span",{class:"info-label"},"Address:",-1)),e.createElementVNode("span",xc,e.toDisplayString(i.vendorInfo.address||((N=i.poDetails.vendorInfo)==null?void 0:N.address)||"N/A"),1)])]),e.createElementVNode("div",Tc,[t[46]||(t[46]=e.createElementVNode("h3",null,"Purchase Order Details",-1)),e.createElementVNode("div",Rc,[t[41]||(t[41]=e.createElementVNode("span",{class:"info-label"},"PO Number:",-1)),e.createElementVNode("span",Ac,e.toDisplayString(i.poDetails.id),1)]),e.createElementVNode("div",Pc,[t[42]||(t[42]=e.createElementVNode("span",{class:"info-label"},"Date:",-1)),e.createElementVNode("span",Mc,e.toDisplayString(i.vendorInfo.poDate||((D=i.poDetails.vendorInfo)==null?void 0:D.poDate)||s.formatDate(new Date)),1)]),e.createElementVNode("div",Ic,[t[43]||(t[43]=e.createElementVNode("span",{class:"info-label"},"Requested By:",-1)),e.createElementVNode("span",Lc,e.toDisplayString(i.vendorInfo.poApproved||((_=i.poDetails.vendorInfo)==null?void 0:_.poApproved)||"N/A"),1)]),e.createElementVNode("div",qc,[t[44]||(t[44]=e.createElementVNode("span",{class:"info-label"},"Department:",-1)),e.createElementVNode("span",zc,"PO-"+e.toDisplayString(i.poDetails.department||"N/A"),1)]),e.createElementVNode("div",Oc,[t[45]||(t[45]=e.createElementVNode("span",{class:"info-label"},"Delivery Date:",-1)),e.createElementVNode("span",Uc,e.toDisplayString(i.poDetails.neededDate||"N/A"),1)])])]),e.createElementVNode("div",jc,[t[55]||(t[55]=e.createElementVNode("h2",{class:"section-title"},"Order Items",-1)),e.createElementVNode("table",Gc,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[t[47]||(t[47]=e.createElementVNode("th",null,"Item #",-1)),t[48]||(t[48]=e.createElementVNode("th",null,"Description",-1)),t[49]||(t[49]=e.createElementVNode("th",null,"Quantity",-1)),t[50]||(t[50]=e.createElementVNode("th",null,"Unit Price",-1)),t[51]||(t[51]=e.createElementVNode("th",null,"Total",-1)),i.isPrinting?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("th",Hc,"Actions"))])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.poDetails.items||[],(d,m)=>(e.openBlock(),e.createElementBlock("tr",{key:m},[e.createElementVNode("td",null,e.toDisplayString(d.itemNumber||m+1),1),e.createElementVNode("td",null,e.toDisplayString(d.desc),1),e.createElementVNode("td",null,e.toDisplayString(d.qty),1),e.createElementVNode("td",null,[d.editing?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":g=>d.tempPrice=g,type:"number",step:"0.01",min:"0",class:e.normalizeClass(["price-input",{"price-changed":d.cost!==d.tempPrice}])},null,10,Jc)),[[e.vModelText,d.tempPrice,void 0,{number:!0}]]):(e.openBlock(),e.createElementBlock("span",Wc,[e.createTextVNode(" $"+e.toDisplayString((d.unitPrice||d.cost||0).toFixed(2))+" ",1),d.cost!==d.unitPrice&&d.unitPrice?(e.openBlock(),e.createElementBlock("span",Qc,"!")):e.createCommentVNode("",!0)]))]),e.createElementVNode("td",null,"$"+e.toDisplayString(((d.unitPrice||d.cost||0)*(d.qty||0)).toFixed(2)),1),i.isPrinting?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("td",Yc,[d.editing?(e.openBlock(),e.createElementBlock("div",Kc,[e.createElementVNode("button",{onClick:g=>s.savePrice(m),class:"save-btn"},"Save",8,$c),e.createElementVNode("button",{onClick:g=>s.cancelEdit(m),class:"cancel-btn"},"Cancel",8,Xc)])):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:g=>s.startEdit(m),class:"edit-btn"}," Edit Price ",8,Zc))]))]))),128))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.poDetails.items||[],(d,m)=>(e.openBlock(),e.createElementBlock("div",{key:"note-"+m},[d.justification?(e.openBlock(),e.createElementBlock("div",vc,[e.createElementVNode("strong",null,"Price Change Justification (Item "+e.toDisplayString(d.itemNumber||m+1)+"):",1),e.createTextVNode(" "+e.toDisplayString(d.justification),1)])):e.createCommentVNode("",!0)]))),128)),e.createElementVNode("div",em,[e.createElementVNode("div",tm,[t[52]||(t[52]=e.createElementVNode("span",null,"Subtotal:",-1)),e.createElementVNode("span",null,"$"+e.toDisplayString(s.subTotal.toFixed(2)),1)]),e.createElementVNode("div",om,[e.createElementVNode("span",null,"Tax ("+e.toDisplayString(i.vendorInfo.tax||((C=i.poDetails.vendorInfo)==null?void 0:C.tax)||0)+"%):",1),e.createElementVNode("span",null,"$"+e.toDisplayString(s.calculateTax().toFixed(2)),1)]),e.createElementVNode("div",nm,[t[53]||(t[53]=e.createElementVNode("span",null,"Shipping:",-1)),e.createElementVNode("span",null,"$"+e.toDisplayString(s.getOptional(i.vendorInfo.shipping)),1)]),e.createElementVNode("div",im,[t[54]||(t[54]=e.createElementVNode("span",null,"Grand Total:",-1)),e.createElementVNode("span",null,"$"+e.toDisplayString(s.grandTotal.toFixed(2)),1)])])])]),i.showJustificationModal?(e.openBlock(),e.createElementBlock("div",{key:0,class:"justification-modal",onClick:t[10]||(t[10]=e.withModifiers((...d)=>s.closeJustificationModal&&s.closeJustificationModal(...d),["self"]))},[e.createElementVNode("div",sm,[t[58]||(t[58]=e.createElementVNode("h3",null,"Price Change Justification Required",-1)),e.createElementVNode("p",lm,[t[56]||(t[56]=e.createTextVNode(" Please provide a justification for changing the price from ",-1)),e.createElementVNode("strong",null,"$"+e.toDisplayString((h=(p=s.currentItem)==null?void 0:p.cost)==null?void 0:h.toFixed(2)),1),t[57]||(t[57]=e.createTextVNode(" to ",-1)),e.createElementVNode("strong",null,"$"+e.toDisplayString((k=(b=s.currentItem)==null?void 0:b.tempPrice)==null?void 0:k.toFixed(2)),1)]),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":t[7]||(t[7]=d=>i.justificationText=d),class:"justification-textarea",placeholder:"Enter justification for price change...",required:""},null,512),[[e.vModelText,i.justificationText]]),e.createElementVNode("div",rm,[e.createElementVNode("button",{onClick:t[8]||(t[8]=(...d)=>s.closeJustificationModal&&s.closeJustificationModal(...d)),class:"cancel-btn"},"Cancel"),e.createElementVNode("button",{onClick:t[9]||(t[9]=(...d)=>s.confirmPriceChange&&s.confirmPriceChange(...d)),class:"save-btn",disabled:!i.justificationText.trim()}," Confirm Change ",8,am)])])])):e.createCommentVNode("",!0),i.isPrinting?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"add-item-btn",onClick:t[11]||(t[11]=d=>s.handleFinishPO(i.poDetails.id))},"Approve PO"))])):e.createCommentVNode("",!0),i.activeTab==="workflow"?(e.openBlock(),e.createElementBlock("div",dm,t[59]||(t[59]=[e.createStaticVNode('<div class="workflow-steps"><div class="workflow-step"><div class="step-icon completed">1</div><div class="step-title">Request Submitted</div></div><div class="workflow-step"><div class="step-icon active">2</div><div class="step-title">Department Review</div></div><div class="workflow-step"><div class="step-icon">3</div><div class="step-title">Management Approval</div></div><div class="workflow-step"><div class="step-icon">4</div><div class="step-title">Purchase Order Created</div></div><div class="workflow-step"><div class="step-icon">5</div><div class="step-title">Order Fulfilled</div></div></div><div style="background:white;padding:30px;border-radius:15px;margin-top:20px;"><h3 style="color:#1e40af;margin-bottom:20px;">Requisition Workflow Process</h3><div style="line-height:1.8;color:#374151;"><p><strong>Step 1: Request Identification</strong><br> Department or individual identifies need for materials, equipment, or services.</p><p><strong>Step 2: Requisition Creation</strong><br> Complete requisition form with detailed specifications, quantities, and business justification.</p><p><strong>Step 3: Department Review</strong><br> Department supervisor reviews request for accuracy, necessity, and budget compliance.</p><p><strong>Step 4: Management Approval</strong><br> Based on cost thresholds, appropriate management level provides approval.</p><p><strong>Step 5: Purchase Order Generation</strong><br> Purchasing team converts approved requisition into formal Purchase Order (PO).</p><p><strong>Step 6: Vendor Processing</strong><br> PO sent to vendor, order processed, and delivery scheduled.</p><p><strong>Step 7: Receipt &amp; Inventory</strong><br> Goods received, inspected, and entered into inventory system.</p></div></div>',2)]))):e.createCommentVNode("",!0)])}const z=F(qa,[["render",cm]]),mm=(o={})=>({brandName:o.brandName||"OceanHelm",logoIcon:o.logoIcon||"bi bi-water",showLogo:o.showLogo!==!1,responsive:o.responsive!==!1,...o}),pm=[{type:"link",label:"Home",icon:"bi bi-house",roles:["owner","staff","captain"],href:"/app/dashboard",active:!0},{type:"button",label:"Guide",icon:"bi bi-compass",action:"guide",roles:["crew"]},{type:"link",label:"Activity Log",icon:"bi bi-activity",href:"/activity-log",roles:["owner"]},{type:"link",label:"People Manager",icon:"bi bi-person-plus",href:"/app/people-manager",roles:["owner"]},{type:"text",label:"Modules"},{type:"dropdown",label:"Compliance",roles:["owner","staff","captain"],icon:"bi bi-list-ul",children:[{label:"Vessel Certification",action:"vessel-cert"},{label:"Reports",action:"reports"},{label:"Crew Certification",action:"crew-cert"},{label:"QHSE Compliance",action:"qhse"},{label:"Track Garbage",action:"garbage"}]},{type:"dropdown",label:"HR",icon:"bi bi-people-fill",roles:["owner","staff"],children:[{label:"Attendance",action:"hr-attendance",roles:["owner","staff"]},{label:"Payroll",action:"hr-payroll",roles:["owner","staff"]},{label:"Appraisals",action:"hr-appraisals",roles:["owner","staff"]},{label:"Leave Management",action:"hr-leave",roles:["owner","staff"]},{label:"Disciplinary Log",action:"hr-disciplinary",roles:["owner"]}]},{type:"button",label:"Maintenance",icon:"bi bi-tools",action:"maintenance",roles:["owner","staff","captain"]},{type:"dropdown",label:"Crew Management",icon:"bi bi-people",roles:["owner","staff","captain"],children:[{label:"All Crew",action:"crew-all",roles:["owner","staff"]},{label:"Get Crew by Vessel",action:"crew-by-vessel"},{label:"Schedule",action:"schedule"}]},{type:"dropdown",label:"Inventory Management",icon:"bi bi-clipboard-data",roles:["owner","staff","captain"],children:[{label:"Parts Inventory",action:"inventory",roles:["owner","staff","captain"]},{label:"Bunkering",action:"fuel",roles:["owner","staff","captain"]}]},{type:"link",label:"Requisition Processing",icon:"bi bi-calendar-check",href:"/app/requisition",roles:["owner","staff","captain"]},{type:"button",label:"Voyage Manager",icon:"fas fa-ship",action:"coming-soon",roles:["owner","staff","captain"]},{type:"button",label:"Vessel Log",icon:"bi bi-file-ruled",action:"coming-soon",roles:["owner","staff","captain"]},{type:"button",label:"Profile",icon:"bi bi-people",action:"crew-profile",roles:["crew"]},{type:"button",label:"Training",icon:"bi bi-book",action:"crew-training",roles:["crew"]},{type:"button",label:"Settings",icon:"bi bi-gear",action:"settings",roles:["owner","staff"]},{type:"button",label:"Help & Support",icon:"bi bi-question-circle",action:"help"}],fm=(o,t)=>!o.roles||o.roles.length===0?!0:o.roles.includes(t==null?void 0:t.role),hm={install(o,t={}){o.component("ConfigurableSidebar",R),o.component("VesselLists",A),o.component("DashHead",P),o.component("Reports",M),o.component("ActivityLogs",L),o.component("CrewManagement",q),o.component("RequisitionSystem",z),o.component("OceanHelmMaintenance",I),o.provide("sidebarConfig",t)}};V.ActivityLogs=L,V.ConfigurableSidebar=R,V.CrewManagement=q,V.DashHead=P,V.OceanHelmMaintenance=I,V.Reports=M,V.RequisitionSystem=z,V.VesselList=A,V.createSidebarConfig=mm,V.default=hm,V.defaultMenuItems=pm,V.defaultPermissionChecker=fm,Object.defineProperties(V,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
9
+ Then describe the drill scenario and findings…`:n.reportForm.entity_type==="incident"?"Describe what happened, when, and where…":"Describe findings, observations, and outcomes…"}," ",8,ys),[[e.vModelText,n.reportForm.findings]])]),n.reportForm.entity_type==="incident"?(e.openBlock(),e.createElementBlock("div",Es,[t[128]||(t[128]=e.createElementVNode("div",{class:"incident-fields-title"},[e.createElementVNode("i",{class:"bi bi-layout-text-window-reverse me-1"}),e.createTextVNode(" Incident Report Fields "),e.createElementVNode("span",{class:"checklist-hint"},"These map directly to the PDF sections")],-1)),e.createElementVNode("div",Ns,[t[117]||(t[117]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Possible Consequences",-1)),t[118]||(t[118]=e.createElementVNode("div",{class:"field-hint"},"e.g. Personal injury, damage, collision, grounding, fire, pollution",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[29]||(t[29]=s=>n.reportForm.inc_consequences=s),placeholder:"Describe possible consequences…"},null,512),[[e.vModelText,n.reportForm.inc_consequences]])]),e.createElementVNode("div",bs,[t[119]||(t[119]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Relevant Factors / Conditions Surrounding the Event",-1)),t[120]||(t[120]=e.createElementVNode("div",{class:"field-hint"},"e.g. weather, lighting, fatigue, time pressure",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[30]||(t[30]=s=>n.reportForm.inc_factors=s),placeholder:"Describe relevant factors and conditions…"},null,512),[[e.vModelText,n.reportForm.inc_factors]])]),e.createElementVNode("div",Vs,[t[121]||(t[121]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Immediate Action Taken",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[31]||(t[31]=s=>n.reportForm.inc_immediate_action=s),placeholder:"What was done immediately after the event?"},null,512),[[e.vModelText,n.reportForm.inc_immediate_action]])]),e.createElementVNode("div",ks,[e.createElementVNode("div",ws,[t[122]||(t[122]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Direct Cause",-1)),t[123]||(t[123]=e.createElementVNode("div",{class:"field-hint"},"e.g. failure to follow procedures, defective equipment ",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"3","onUpdate:modelValue":t[32]||(t[32]=s=>n.reportForm.inc_direct_cause=s),placeholder:"Direct cause of the event…"},null,512),[[e.vModelText,n.reportForm.inc_direct_cause]])]),e.createElementVNode("div",Cs,[t[124]||(t[124]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Root Cause",-1)),t[125]||(t[125]=e.createElementVNode("div",{class:"field-hint"},"e.g. lack of training, management factors",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"3","onUpdate:modelValue":t[33]||(t[33]=s=>n.reportForm.inc_root_cause=s),placeholder:"Root / underlying cause…"},null,512),[[e.vModelText,n.reportForm.inc_root_cause]])])]),e.createElementVNode("div",Ds,[t[126]||(t[126]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Action Taken to Avoid Re-occurrence",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[34]||(t[34]=s=>n.reportForm.correctiveActions=s),placeholder:"Corrective actions and preventive measures…"},null,512),[[e.vModelText,n.reportForm.correctiveActions]])]),e.createElementVNode("div",_s,[t[127]||(t[127]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Any Other Remarks",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"2","onUpdate:modelValue":t[35]||(t[35]=s=>n.reportForm.inc_remarks=s),placeholder:"Additional remarks…"},null,512),[[e.vModelText,n.reportForm.inc_remarks]])])])):(e.openBlock(),e.createElementBlock("div",us,[t[129]||(t[129]=e.createElementVNode("label",{class:"form-label fw-semibold"},"Corrective Actions",-1)),e.withDirectives(e.createElementVNode("textarea",{class:"form-control",rows:"3","onUpdate:modelValue":t[36]||(t[36]=s=>n.reportForm.correctiveActions=s),placeholder:"List any corrective actions required or taken…"},null,512),[[e.vModelText,n.reportForm.correctiveActions]])])),e.createElementVNode("div",Ss,[t[133]||(t[133]=e.createElementVNode("label",{class:"form-label fw-semibold"},[e.createTextVNode(" Attach Files "),e.createElementVNode("span",{class:"form-hint"},"Images embed in PDF · all files go into the ZIP")],-1)),e.createElementVNode("div",{class:"file-drop-zone",onClick:t[37]||(t[37]=s=>o.$refs.reportFileInput.click()),onDragover:t[38]||(t[38]=e.withModifiers(()=>{},["prevent"])),onDrop:t[39]||(t[39]=e.withModifiers((...s)=>i.handleReportFileDrop&&i.handleReportFileDrop(...s),["prevent"]))},[t[131]||(t[131]=e.createElementVNode("i",{class:"bi bi-cloud-upload",style:{"font-size":"2rem",color:"#6c757d"}},null,-1)),t[132]||(t[132]=e.createElementVNode("p",{class:"mb-0 mt-2 text-muted"},"Click or drag files here (PNG, JPG, PDF…)",-1)),n.reportForm.files.length>0?(e.openBlock(),e.createElementBlock("div",Fs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.reportForm.files,(s,a)=>(e.openBlock(),e.createElementBlock("span",{class:"attached-chip",key:a},[e.createElementVNode("i",{class:e.normalizeClass(["bi me-1",i.fileIcon(s.type)])},null,2),e.createTextVNode(e.toDisplayString(s.name)+" ",1),e.createElementVNode("button",{onClick:e.withModifiers(c=>i.removeReportFile(a),["stop"])},t[130]||(t[130]=[e.createElementVNode("i",{class:"bi bi-x"},null,-1)]),8,Bs)]))),128))])):e.createCommentVNode("",!0)],32),e.createElementVNode("input",{ref:"reportFileInput",type:"file",multiple:"",style:{display:"none"},onChange:t[40]||(t[40]=(...s)=>i.handleReportFileAttach&&i.handleReportFileAttach(...s))},null,544)]),n.reportForm.title||n.reportForm.files.length>0?(e.openBlock(),e.createElementBlock("div",xs,[t[134]||(t[134]=e.createElementVNode("i",{class:"bi bi-file-zip me-1"},null,-1)),t[135]||(t[135]=e.createTextVNode(" Download will produce ",-1)),e.createElementVNode("strong",null,e.toDisplayString(i.zipName)+".zip",1),t[136]||(t[136]=e.createTextVNode(" containing the report PDF ",-1)),n.reportForm.files.length?(e.openBlock(),e.createElementBlock("span",Ts," + "+e.toDisplayString(n.reportForm.files.length)+" attachment"+e.toDisplayString(n.reportForm.files.length!==1?"s":""),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Rs,[e.createElementVNode("button",{type:"button",class:"btn btn-secondary",onClick:t[41]||(t[41]=(...s)=>i.closeReportForm&&i.closeReportForm(...s))},"Cancel"),e.createElementVNode("button",{type:"button",class:"btn btn-success",onClick:t[42]||(t[42]=(...s)=>i.requestSubmitReport&&i.requestSubmitReport(...s)),disabled:r.isSubmitting||!n.reportForm.title||!n.reportForm.submittedBy||!n.reportForm.findings},[r.isSubmitting?(e.openBlock(),e.createElementBlock("span",Ps,t[137]||(t[137]=[e.createElementVNode("span",{class:"spinner-sm"},null,-1),e.createTextVNode(" Submitting…",-1)]))):(e.openBlock(),e.createElementBlock("span",Ms,t[138]||(t[138]=[e.createElementVNode("i",{class:"bi bi-check-circle me-1"},null,-1),e.createTextVNode("Submit Report",-1)])))],8,As)])])])],2),e.createElementVNode("div",{class:e.normalizeClass(["modal",{show:n.showViewModal}]),onClick:t[48]||(t[48]=e.withModifiers((...s)=>i.closeViewer&&i.closeViewer(...s),["self"]))},[e.createElementVNode("div",Is,[n.viewingReport?(e.openBlock(),e.createElementBlock("div",Ls,[e.createElementVNode("div",qs,[e.createElementVNode("div",zs,[e.createElementVNode("span",{class:e.normalizeClass(["entity-chip me-2",i.reportTypeClass(n.viewingReport)])},e.toDisplayString(i.reportTypeLabel(n.viewingReport)),3),e.createElementVNode("strong",Os,e.toDisplayString(n.viewingReport.title),1)]),e.createElementVNode("button",{type:"button",class:"btn-close btn-close-white",onClick:t[44]||(t[44]=(...s)=>i.closeViewer&&i.closeViewer(...s))})]),e.createElementVNode("div",Us,[e.createElementVNode("div",js,[e.createElementVNode("div",Gs,[t[139]||(t[139]=e.createElementVNode("label",null,"Reference",-1)),e.createElementVNode("span",Hs,e.toDisplayString(n.viewingReport.entityRef||"—"),1)]),e.createElementVNode("div",Ws,[t[140]||(t[140]=e.createElementVNode("label",null,"Type",-1)),e.createElementVNode("span",null,e.toDisplayString(i.reportTypeLabel(n.viewingReport)),1)]),n.viewingReport.manualCategory?(e.openBlock(),e.createElementBlock("div",Qs,[t[141]||(t[141]=e.createElementVNode("label",null,"Category",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.manualCategory),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Js,[t[142]||(t[142]=e.createElementVNode("label",null,"Submitted By",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.submittedBy),1)]),e.createElementVNode("div",Ys,[t[143]||(t[143]=e.createElementVNode("label",null,"Date",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.date),1)]),n.viewingReport.vessel?(e.openBlock(),e.createElementBlock("div",Zs,[t[144]||(t[144]=e.createElementVNode("label",null,"Vessel / Location",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.vessel),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Ks,[t[145]||(t[145]=e.createElementVNode("label",null,"Submitted At",-1)),e.createElementVNode("span",null,e.toDisplayString(i.formatDate(n.viewingReport.submittedAt)),1)]),n.viewingReport.entity_subtype?(e.openBlock(),e.createElementBlock("div",$s,[t[146]||(t[146]=e.createElementVNode("label",null,"Drill Type",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.entity_subtype),1)])):e.createCommentVNode("",!0),n.viewingReport.entity_creator?(e.openBlock(),e.createElementBlock("div",Xs,[t[147]||(t[147]=e.createElementVNode("label",null,"Drill Master",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.entity_creator),1)])):e.createCommentVNode("",!0),n.viewingReport.entity_duration?(e.openBlock(),e.createElementBlock("div",vs,[t[148]||(t[148]=e.createElementVNode("label",null,"Duration",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.entity_duration),1)])):e.createCommentVNode("",!0),n.viewingReport.entity_participants?(e.openBlock(),e.createElementBlock("div",en,[t[149]||(t[149]=e.createElementVNode("label",null,"Participants",-1)),e.createElementVNode("span",null,e.toDisplayString(n.viewingReport.entity_participants),1)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",tn,[t[150]||(t[150]=e.createElementVNode("label",null,"Findings / Summary",-1)),e.createElementVNode("div",on,e.toDisplayString(n.viewingReport.findings),1)]),n.viewingReport.correctiveActions?(e.openBlock(),e.createElementBlock("div",sn,[t[151]||(t[151]=e.createElementVNode("label",null,"Corrective Actions",-1)),e.createElementVNode("div",nn,e.toDisplayString(n.viewingReport.correctiveActions),1)])):e.createCommentVNode("",!0),i.getFilesForReport(n.viewingReport.id).length>0?(e.openBlock(),e.createElementBlock("div",ln,[t[153]||(t[153]=e.createElementVNode("label",null,"Attachments",-1)),e.createElementVNode("div",rn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.getFilesForReport(n.viewingReport.id),s=>(e.openBlock(),e.createElementBlock("a",{key:s.id,href:s.publicUrl,target:"_blank",rel:"noopener",class:"attached-chip attached-chip--link"},[e.createElementVNode("i",{class:e.normalizeClass(["bi me-1",i.fileIcon(s.type)])},null,2),e.createTextVNode(e.toDisplayString(s.name)+" ",1),e.createElementVNode("small",dn,"("+e.toDisplayString(i.formatFileSize(s.size))+")",1),t[152]||(t[152]=e.createElementVNode("i",{class:"bi bi-box-arrow-up-right ms-1",style:{"font-size":"10px"}},null,-1))],8,an))),128))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",cn,[e.createElementVNode("button",{class:"btn btn-danger btn-sm me-auto",onClick:t[45]||(t[45]=s=>i.requestDeleteReport(n.viewingReport.id))},t[154]||(t[154]=[e.createElementVNode("i",{class:"bi bi-trash"},null,-1),e.createTextVNode(" Delete ",-1)])),e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[46]||(t[46]=(...s)=>i.closeViewer&&i.closeViewer(...s))},"Close"),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[47]||(t[47]=s=>i.downloadReport(n.viewingReport)),disabled:n.generatingPdf===n.viewingReport.id},[n.generatingPdf===n.viewingReport.id?(e.openBlock(),e.createElementBlock("span",pn,t[155]||(t[155]=[e.createElementVNode("span",{class:"spinner-sm"},null,-1),e.createTextVNode(" Building ZIP…",-1)]))):(e.openBlock(),e.createElementBlock("span",fn,t[156]||(t[156]=[e.createElementVNode("i",{class:"bi bi-file-zip me-1"},null,-1),e.createTextVNode("Download ZIP",-1)])))],8,mn)])])):e.createCommentVNode("",!0)])],2),e.createElementVNode("input",{ref:"fileInput",type:"file",multiple:"",style:{display:"none"},onChange:t[49]||(t[49]=(...s)=>i.handleFileSelection&&i.handleFileSelection(...s))},null,544)])}const M=S(ze,[["render",hn],["__scopeId","data-v-9e048de6"]]),gn={name:"OceanHelmMaintenance",props:{vesselInfo:{type:Object,required:!0},tasks:{type:Array,default:()=>[]},vesselCrew:{type:Array,default:()=>[]},companyInfo:{type:Object,default:()=>({})},userProfile:{type:Object,required:!0}},emits:["dashboard-navigate","load-checklist","save-schedule","update-task","upload-file","delete-evidence","access-denied","show-message","generate-checklist"],data(){return{ready:!0,isSaving:!1,after:null,lastSection:"",currentTask:"",imgText:"Choose file to upload",fileText:"Drag and drop files here or",fileattachments:{},refreshKey:0,activeSection:"inventory",sections:[{id:"schedule",name:"Schedule",icon:"📅"},{id:"inventory",name:"All Maintenance",icon:"♻️"},{id:"dashboard",name:"Dashboard",icon:"☰",onClick:()=>this.$emit("dashboard-navigate")}],activeFilter:"all",searchQuery:"",checklists:[],isLoading:!1,form:{taskName:"",description:"",maintenanceType:"",component:"",priority:"",dueDate:"",estimatedHours:null,assignedTo:"",recurrence:"",lastPerformed:"",nextDue:"",notifyEmail:!0,notifySms:!0,reminderDays:"1",estimatedDuration:null,notes:"",status:"Soon",email:"",remainingDays:null,attachments:{}},maintenanceTasks:[],showReport:!1,reportDate:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),reportId:"MT-"+Math.random().toString(36).substr(2,9).toUpperCase()}},watch:{"form.lastPerformed":"calculateNextDue","form.recurrence":"calculateNextDue","form.nextDue":function(o){this.calculateRemainingDays()}},computed:{filteredTasks(){let o=[...this.tasks];if(this.activeFilter==="all"?o=o.filter(t=>t.status==="Overdue"||t.status==="Soon"||t.status==="Completed"):this.activeFilter==="due"?o=o.filter(t=>t.status==="Overdue"||t.status==="Soon"):this.activeFilter==="completed"&&(o=o.filter(t=>t.status==="Completed")),this.searchQuery){const t=this.searchQuery.toLowerCase();o=o.filter(r=>r.component.toLowerCase().includes(t)||r.taskName.toLowerCase().includes(t)||r.assignedTo.toLowerCase().includes(t))}return o},completedCount(){return this.checklists.filter(o=>o.completed)},progress(){return Math.round(this.completedCount.length/this.checklists.length*100)},checklistButtonLabel(){return this.lastSection==="schedule"?"Approve Maintenance":"Save Checklist"},showAddTaskButton(){return this.checklistButtonLabel!=="Save Checklist"},totalEstimatedHours(){return this.maintenanceTasks.reduce((o,t)=>o+(t.estimatedHours||0),0)}},methods:{grantAccess(o){const t=this.userProfile;return t.role==="owner"||t.role==="staff"||t.role==="captain"&&t.vessel===o},deepAccess(){const o=this.userProfile;return o.role==="owner"||o.role==="captain"?!0:(this.$emit("access-denied","You do not have access to do this"),!1)},deleteTask(o){this.checklists=this.checklists.filter(t=>t.id!==o)},addTask(o){o&&o.preventDefault(),this.$emit("show-message",{type:"prompt",title:"Add New Task",message:"Enter the task details",callback:t=>{if(t){const r={id:Date.now(),text:t,completed:!1};this.checklists.push(r)}}})},setFilter(o){this.activeFilter=o},loadChecklist(o){this.isLoading=!0,this.$emit("generate-checklist",{component:o,callback:t=>{this.checklists=t.map(r=>({...r,completed:!1})),this.isLoading=!1}})},showMaintenance(o){if(this.deepAccess()){const t=this.tasks.find(r=>r.component===o);t&&t.checklistProgress?this.checklists=[...t.checklistProgress]:this.loadChecklist(o),this.after=t==null?void 0:t.after,this.currentTask=o,this.lastSection="inventory",this.activeSection="maintenance"}},printMaintenance(o){const t=this.tasks.find(r=>r.component===o);this.maintenanceTasks=[t],this.loadMaintenanceData(),this.showReport=!0,this.$nextTick(()=>{setTimeout(()=>{window.print(),this.showReport=!1},100)})},switchSchedule(){this.deepAccess()&&(this.activeSection="schedule")},handleFiles(o){this.imgText=o.target.files[0].name,this.form.attachments={file:o.target.files[0]}},handleImg(o){this.fileText=o.target.files[0].name,this.fileattachments={file:o.target.files[0]}},validateForm(){const o=["taskName","description","maintenanceType","component","priority","estimatedHours","recurrence","lastPerformed","assignedTo"];for(const t of o)if(!this.form[t])return this.$emit("show-message",{type:"error",title:"Missing info",message:`Please fill in the required field: ${t}`}),!1;return!0},handleSectionClick(o){this.activeSection=o.id,typeof o.onClick=="function"&&o.onClick()},calculateNextDue(){const o=this.form.lastPerformed?new Date(this.form.lastPerformed):null,t=this.form.recurrence;if(!o||!t)return;let r=new Date(o);switch(t){case"daily":r.setDate(r.getDate()+1);break;case"weekly":r.setDate(r.getDate()+7);break;case"monthly":r.setMonth(r.getMonth()+1);break;case"quarterly":r.setMonth(r.getMonth()+3);break;case"semi-annual":r.setMonth(r.getMonth()+6);break;case"annual":r.setFullYear(r.getFullYear()+1);break;case"once":case"custom":return}this.form.nextDue=r.toISOString().split("T")[0]},calculateRemainingDays(){if(!this.form.nextDue){this.form.remainingDays=null;return}const o=new Date,t=new Date(this.form.nextDue);o.setHours(0,0,0,0),t.setHours(0,0,0,0);const r=t-o,l=Math.ceil(r/(1e3*60*60*24));this.form.remainingDays=`${l} Days`},async saveSchedule(){if(this.isSaving=!0,!this.validateForm()){this.isSaving=!1;return}const o={...this.form};if(this.form.component==="Other"&&this.form.customComponent&&(o.component=this.form.customComponent),o.email=this.companyInfo.email,this.tasks.some(r=>r.component===o.component)){this.$emit("show-message",{type:"error",title:"Duplicate Component",message:`A task with the component "${o.component}" already exists in maintenance`}),this.isSaving=!1;return}delete o.customComponent,this.$emit("save-schedule",{taskData:o,file:o.attachments.file,callback:r=>{this.isSaving=!1,r&&(this.loadChecklist(o.component),this.lastSection="schedule",this.currentTask=o.component,this.resetForm(),this.activeSection="maintenance")}})},resetForm(){this.form={taskName:"",description:"",maintenanceType:"",component:"",priority:"",dueDate:"",estimatedHours:null,assignedTo:"",recurrence:"",lastPerformed:"",nextDue:"",notifyEmail:!0,notifySms:!0,reminderDays:"1",estimatedDuration:null,notes:"",status:"Soon",remainingDays:null,attachments:{}}},toggleTask(o){o.completed=!o.completed},async resetTasks(){const t=this.checklists.every(l=>l.completed)?"Completed":"Soon",r={checklistProgress:[...this.checklists],status:t,component:this.currentTask,after:this.after};this.$emit("update-task",{updateData:r,file:this.fileattachments.file,tasks:this.tasks,callback:(l,n)=>{l&&(n&&(this.after=n),this.fileattachments={},this.fileText="Drag and drop files here or",this.refreshKey+=1,this.activeSection="inventory")}})},loadMaintenanceData(){this.reportId="MT-"+Math.random().toString(36).substr(2,9).toUpperCase(),this.reportDate=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})},formatDate(o){return o?new Date(o).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"N/A"},getTaskStatusClass(o){return o.status==="Completed"?"completed":o.status==="Overdue"?"overdue":o.status==="In Progress"?"in-progress":"pending"},getChecklistProgress(o){if(!o.checklistProgress||o.checklistProgress.length===0)return 0;const t=o.checklistProgress.filter(r=>r.completed).length;return Math.round(t/o.checklistProgress.length*100)},getCompletedChecklistItems(o){return o.checklistProgress?o.checklistProgress.filter(t=>t.completed).length:0},generateRecommendations(){return["Maintain regular communication with assigned technicians","Ensure all safety protocols are followed during maintenance activities","Update task progress and notes in real-time for accurate reporting"]},deleteEvidence(){this.$emit("delete-evidence",{currentTask:this.currentTask,callback:o=>{o&&(this.after=null,this.fileText="Drag and drop files here or",this.fileattachments={},this.refreshKey+=1)}})}}},yn={key:0},En=["onClick"],Nn={class:"content"},bn={key:0,class:"loading-container"},Vn={key:1},kn={class:"container"},wn={class:"d-flex justify-content-between align-items-center"},Cn={class:"progress-container"},Dn={class:"progress-info"},_n={class:"progress-bar"},un={class:"checklist"},Sn=["onClick"],Fn={key:0},Bn=["onClick"],xn=["onClick"],Tn={key:0},Rn={class:"checklist"},An={class:"checklist-item"},Pn={class:"attachment-area"},Mn={key:2,class:"status"},In={class:"form-group"},Ln={class:"form-group"},qn={class:"input-group"},zn={class:"form-group"},On={class:"form-group"},Un={class:"input-group"},jn={class:"form-group"},Gn={class:"form-group"},Hn={class:"input-group"},Wn={class:"form-group"},Qn={class:"form-group"},Jn=["value"],Yn={class:"input-group"},Zn={class:"form-group"},Kn={class:"input-group"},$n={class:"form-group"},Xn={class:"form-group"},vn={class:"form-group"},ei={class:"checkbox-group"},ti={class:"checkbox-item"},oi={class:"checkbox-item"},si={class:"input-group"},ni={class:"form-group"},ii={class:"form-group"},li={class:"form-group"},ri={class:"attachment-area"},ai={class:"action-buttons"},di=["disabled"],ci={class:"task-table-wrapper"},mi={class:"table-controls"},pi={class:"filters"},fi={class:"task-table"},hi=["onClick"],gi=["onClick"],yi={key:0},Ei={class:"alert alert-primary",role:"alert"},Ni={class:"mb-0"},bi={class:"report-container",ref:"reportContainer"},Vi={class:"report-info"},ki={class:"info-box"},wi={class:"info-box"},Ci={class:"info-box"},Di={class:"section"},_i={class:"summary-grid"},ui={class:"summary-card"},Si={class:"summary-number"},Fi={class:"section"},Bi={class:"task-header"},xi={class:"task-title"},Ti={class:"task-component"},Ri={class:"task-details"},Ai={class:"detail-item"},Pi={class:"detail-value"},Mi={class:"detail-item"},Ii={class:"detail-value"},Li={class:"detail-item"},qi={class:"detail-value"},zi={class:"detail-item"},Oi={class:"detail-value"},Ui={class:"detail-item"},ji={class:"detail-value"},Gi={class:"detail-item"},Hi={class:"detail-value"},Wi={key:0,style:{margin:"15px 0",padding:"10px",background:"white","border-radius":"5px"}},Qi={class:"detail-value"},Ji={key:1,style:{margin:"15px 0",padding:"10px",background:"white","border-radius":"5px"}},Yi={class:"detail-value"},Zi={key:2,class:"checklist-progress"},Ki={class:"progress-bar"},$i={style:{"font-size":"0.9em",color:"#666","margin-top":"5px"}},Xi={class:"checklist-items"},vi={class:"checklist-icon"},el={class:"section"},tl={class:"info-box"},ol={class:"signature-section"},sl={class:"signature-box"},nl={style:{"margin-top":"10px",color:"#666"}};function il(o,t,r,l,n,i){return n.ready?(e.openBlock(),e.createElementBlock("div",yn,[e.createElementVNode("div",null,[e.withDirectives(e.createElementVNode("nav",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.sections,s=>(e.openBlock(),e.createElementBlock("button",{key:s.id,class:e.normalizeClass(["nav-btn",{active:n.activeSection===s.id}]),onClick:a=>i.handleSectionClick(s)},e.toDisplayString(s.icon)+" "+e.toDisplayString(s.name),11,En))),128))],512),[[e.vShow,!n.showReport]]),e.withDirectives(e.createElementVNode("div",Nn,[e.withDirectives(e.createElementVNode("section",{class:e.normalizeClass(["form-section",{active:n.activeSection==="maintenance"}])},[t[37]||(t[37]=e.createElementVNode("h2",null,"🛠️ Maintenance Tasks",-1)),n.isLoading?(e.openBlock(),e.createElementBlock("div",bn,t[27]||(t[27]=[e.createElementVNode("div",{class:"loading-spinner"},null,-1),e.createElementVNode("p",null,"Loading checklist...",-1)]))):e.createCommentVNode("",!0),n.isLoading?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("form",Vn,[e.createElementVNode("div",kn,[e.createElementVNode("div",wn,[t[29]||(t[29]=e.createElementVNode("h1",null,"Maintenance Checklist",-1)),i.showAddTaskButton?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-outline-custom",onClick:t[0]||(t[0]=e.withModifiers(s=>i.addTask(),["prevent"]))},t[28]||(t[28]=[e.createTextVNode(" Manually Add Task ",-1),e.createElementVNode("i",{class:"fas fa-plus"},null,-1)]))):e.createCommentVNode("",!0)]),e.createElementVNode("div",Cn,[e.createElementVNode("div",Dn," Progress: "+e.toDisplayString(i.progress)+"% ("+e.toDisplayString(i.completedCount.length)+"/"+e.toDisplayString(n.checklists.length)+") ",1),e.createElementVNode("div",_n,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:i.progress+"%"})},null,4)])]),e.createElementVNode("ul",un,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.checklists,s=>(e.openBlock(),e.createElementBlock("li",{key:s.id,class:"checklist-item"},[e.createElementVNode("div",{class:e.normalizeClass(["checkbox",{checked:s.completed}]),onClick:a=>i.toggleTask(s)},[s.completed?(e.openBlock(),e.createElementBlock("span",Fn,"✓")):e.createCommentVNode("",!0)],10,Sn),e.createElementVNode("span",{class:e.normalizeClass(["task-text",{completed:s.completed}]),onClick:a=>i.toggleTask(s)},e.toDisplayString(s.text),11,Bn),i.showAddTaskButton?(e.openBlock(),e.createElementBlock("button",{key:0,class:"delete-btn",onClick:a=>i.deleteTask(s.id),title:"Delete task"},t[30]||(t[30]=[e.createStaticVNode('<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3,6 5,6 21,6"></polyline><path d="m19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>',1)]),8,xn)):e.createCommentVNode("",!0)]))),128))]),n.after?(e.openBlock(),e.createElementBlock("div",Tn,[t[33]||(t[33]=e.createElementVNode("label",null,"Upload Image Evidence",-1)),e.createElementVNode("ul",Rn,[e.createElementVNode("li",An,[t[32]||(t[32]=e.createElementVNode("span",{class:"task-text"}," Image Evidence Already Uploaded ",-1)),e.createElementVNode("button",{type:"button",class:"delete-btn",onClick:t[1]||(t[1]=s=>i.deleteEvidence()),title:"Delete Image"},t[31]||(t[31]=[e.createStaticVNode('<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3,6 5,6 21,6"></polyline><path d="m19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>',1)]))])])])):(e.openBlock(),e.createElementBlock("div",{class:"form-group",key:n.refreshKey||"default"},[t[35]||(t[35]=e.createElementVNode("label",null,"Upload Image Evidence",-1)),t[36]||(t[36]=e.createElementVNode("p",null,"You can only upload one image evidence here.",-1)),e.createElementVNode("div",Pn,[e.createElementVNode("p",null,e.toDisplayString(n.fileText),1),e.createElementVNode("input",{type:"file",id:"evidence-files",class:"file-input",onChange:t[2]||(t[2]=(...s)=>i.handleImg&&i.handleImg(...s))},null,32),t[34]||(t[34]=e.createElementVNode("label",{for:"evidence-files",class:"file-label"},"Browse Files",-1))])])),i.completedCount===n.checklists.length?(e.openBlock(),e.createElementBlock("div",Mn," All tasks completed! ✅ ")):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"reset-button",onClick:t[3]||(t[3]=e.withModifiers((...s)=>i.resetTasks&&i.resetTasks(...s),["prevent"]))},e.toDisplayString(i.checklistButtonLabel),1)])]))],2),[[e.vShow,n.activeSection==="maintenance"]]),e.withDirectives(e.createElementVNode("section",{class:e.normalizeClass(["form-section",{active:n.activeSection==="schedule"}])},[t[62]||(t[62]=e.createElementVNode("h2",null,"📅 Maintenance Schedule",-1)),e.createElementVNode("form",null,[e.createElementVNode("div",In,[t[38]||(t[38]=e.createElementVNode("label",{for:"task-name"},"Task Name",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"task-name","onUpdate:modelValue":t[4]||(t[4]=s=>n.form.taskName=s),required:""},null,512),[[e.vModelText,n.form.taskName]])]),e.createElementVNode("div",Ln,[t[39]||(t[39]=e.createElementVNode("label",{for:"task-description"},"Description",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"task-description","onUpdate:modelValue":t[5]||(t[5]=s=>n.form.description=s),required:""},null,512),[[e.vModelText,n.form.description]])]),e.createElementVNode("div",qn,[e.createElementVNode("div",zn,[t[41]||(t[41]=e.createElementVNode("label",{for:"maintenance-type"},"Maintenance Type",-1)),e.withDirectives(e.createElementVNode("select",{id:"maintenance-type","onUpdate:modelValue":t[6]||(t[6]=s=>n.form.maintenanceType=s),required:""},t[40]||(t[40]=[e.createStaticVNode('<option value="">-- Select Type --</option><option value="preventive">Preventive</option><option value="corrective">Corrective</option><option value="predictive">Predictive</option><option value="condition">Condition-Based</option>',5)]),512),[[e.vModelSelect,n.form.maintenanceType]])]),e.createElementVNode("div",On,[t[43]||(t[43]=e.createElementVNode("label",{for:"component"},"Component/System",-1)),e.withDirectives(e.createElementVNode("select",{id:"component","onUpdate:modelValue":t[7]||(t[7]=s=>n.form.component=s),required:""},t[42]||(t[42]=[e.createStaticVNode('<option value="">-- Select Component --</option><option value="engine">Engine</option><option value="hull">Hull</option><option value="electronics">Electronics</option><option value="deck">Deck Machinery</option><option value="plumbing">Plumbing</option><option value="electrical">Electrical</option><option value="hvac">HVAC</option><option value="safety">Safety Systems</option><option value="Other">Other</option>',10)]),512),[[e.vModelSelect,n.form.component]]),n.form.component==="Other"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,type:"text",placeholder:"Enter custom component/system","onUpdate:modelValue":t[8]||(t[8]=s=>n.form.customComponent=s),style:{"margin-top":"8px"}},null,512)),[[e.vModelText,n.form.customComponent]]):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Un,[e.createElementVNode("div",jn,[t[45]||(t[45]=e.createElementVNode("label",{for:"priority"},"Priority",-1)),e.withDirectives(e.createElementVNode("select",{id:"priority","onUpdate:modelValue":t[9]||(t[9]=s=>n.form.priority=s),required:""},t[44]||(t[44]=[e.createElementVNode("option",{value:"low"},"Low",-1),e.createElementVNode("option",{value:"medium"},"Medium",-1),e.createElementVNode("option",{value:"high"},"High",-1),e.createElementVNode("option",{value:"critical"},"Critical",-1)]),512),[[e.vModelSelect,n.form.priority]])]),e.createElementVNode("div",Gn,[t[46]||(t[46]=e.createElementVNode("label",{for:"status"},"Status",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"status","onUpdate:modelValue":t[10]||(t[10]=s=>n.form.status=s),readonly:""},null,512),[[e.vModelText,n.form.status]])])]),e.createElementVNode("div",Hn,[e.createElementVNode("div",Wn,[t[47]||(t[47]=e.createElementVNode("label",{for:"estimated-hours"},"Estimated Hours",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",id:"estimated-hours","onUpdate:modelValue":t[11]||(t[11]=s=>n.form.estimatedHours=s),min:"0",step:"0.5"},null,512),[[e.vModelText,n.form.estimatedHours]])])]),e.createElementVNode("div",Qn,[t[49]||(t[49]=e.createElementVNode("label",{for:"assigned-to"},"Assigned To",-1)),e.withDirectives(e.createElementVNode("select",{id:"assigned-to","onUpdate:modelValue":t[12]||(t[12]=s=>n.form.assignedTo=s)},[t[48]||(t[48]=e.createElementVNode("option",{value:""},"-- Select Personnel --",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.vesselCrew,s=>(e.openBlock(),e.createElementBlock("option",{key:s.id,value:`${s.name} - ${s.role}`},e.toDisplayString(s.name)+" - "+e.toDisplayString(s.role),9,Jn))),128))],512),[[e.vModelSelect,n.form.assignedTo]])]),e.createElementVNode("div",Yn,[e.createElementVNode("div",Zn,[t[51]||(t[51]=e.createElementVNode("label",{for:"recurrence-type"},"Recurrence",-1)),e.withDirectives(e.createElementVNode("select",{id:"recurrence-type","onUpdate:modelValue":t[13]||(t[13]=s=>n.form.recurrence=s),required:""},t[50]||(t[50]=[e.createStaticVNode('<option value="once">One-time</option><option value="daily">Daily</option><option value="weekly">Weekly</option><option value="monthly">Monthly</option><option value="quarterly">Quarterly</option><option value="semi-annual">Semi-annually</option><option value="annual">Annually</option><option value="custom">Custom Interval</option>',8)]),512),[[e.vModelSelect,n.form.recurrence]])])]),e.createElementVNode("div",Kn,[e.createElementVNode("div",$n,[t[52]||(t[52]=e.createElementVNode("label",{for:"last-performed"},"Last Performed Date",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",id:"last-performed","onUpdate:modelValue":t[14]||(t[14]=s=>n.form.lastPerformed=s)},null,512),[[e.vModelText,n.form.lastPerformed]])]),e.createElementVNode("div",Xn,[t[53]||(t[53]=e.createElementVNode("label",{for:"next-due"},"Due Date",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",id:"next-due","onUpdate:modelValue":t[15]||(t[15]=s=>n.form.nextDue=s),required:""},null,512),[[e.vModelText,n.form.nextDue]])])]),e.createElementVNode("div",vn,[t[56]||(t[56]=e.createElementVNode("label",null,"Notifications",-1)),e.createElementVNode("div",ei,[e.createElementVNode("div",ti,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"notify-email","onUpdate:modelValue":t[16]||(t[16]=s=>n.form.notifyEmail=s)},null,512),[[e.vModelCheckbox,n.form.notifyEmail]]),t[54]||(t[54]=e.createElementVNode("label",{for:"notify-email"},"Email Notification",-1))]),e.createElementVNode("div",oi,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"notify-sms","onUpdate:modelValue":t[17]||(t[17]=s=>n.form.notifySms=s)},null,512),[[e.vModelCheckbox,n.form.notifySms]]),t[55]||(t[55]=e.createElementVNode("label",{for:"notify-sms"},"SMS Notification",-1))])])]),e.createElementVNode("div",si,[e.createElementVNode("div",ni,[t[58]||(t[58]=e.createElementVNode("label",{for:"reminder-days"},"Reminder (Days Before)",-1)),e.withDirectives(e.createElementVNode("select",{id:"reminder-days","onUpdate:modelValue":t[18]||(t[18]=s=>n.form.reminderDays=s)},t[57]||(t[57]=[e.createStaticVNode('<option value="1">1 day</option><option value="3">3 days</option><option value="7">1 week</option><option value="14">2 weeks</option><option value="30">1 month</option>',5)]),512),[[e.vModelSelect,n.form.reminderDays]])])]),e.createElementVNode("div",ii,[t[59]||(t[59]=e.createElementVNode("label",{for:"schedule-notes"},"Notes",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"schedule-notes","onUpdate:modelValue":t[19]||(t[19]=s=>n.form.notes=s)},null,512),[[e.vModelText,n.form.notes]])]),e.createElementVNode("div",li,[t[61]||(t[61]=e.createElementVNode("label",null,"Attachments",-1)),e.createElementVNode("div",ri,[e.createElementVNode("p",null,e.toDisplayString(n.imgText),1),e.createElementVNode("input",{type:"file",id:"maintenance-files",class:"file-input",onChange:t[20]||(t[20]=(...s)=>i.handleFiles&&i.handleFiles(...s)),multiple:""},null,32),t[60]||(t[60]=e.createElementVNode("label",{for:"maintenance-files",class:"file-label"},"Browse Files",-1))])]),e.createElementVNode("div",ai,[e.createElementVNode("button",{type:"button",class:"btn btn-primary",onClick:t[21]||(t[21]=e.withModifiers((...s)=>i.saveSchedule&&i.saveSchedule(...s),["prevent"])),disabled:n.isSaving},e.toDisplayString(n.isSaving?"Saving...":"Save Schedule"),9,di)])])],2),[[e.vShow,n.activeSection==="schedule"]]),e.withDirectives(e.createElementVNode("section",{class:e.normalizeClass(["form-section",{active:n.activeSection==="inventory"}])},[t[68]||(t[68]=e.createElementVNode("h2",null,"All Maintenance",-1)),e.createElementVNode("div",ci,[e.createElementVNode("div",mi,[e.createElementVNode("div",pi,[e.createElementVNode("button",{class:e.normalizeClass({active:n.activeFilter==="due"}),onClick:t[22]||(t[22]=s=>i.setFilter("due"))},"Due",2),e.createElementVNode("button",{class:e.normalizeClass({active:n.activeFilter==="all"}),onClick:t[23]||(t[23]=s=>i.setFilter("all"))},"All",2),e.createElementVNode("button",{class:e.normalizeClass({active:n.activeFilter==="completed"}),onClick:t[24]||(t[24]=s=>i.setFilter("completed"))},"Completed",2),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":t[25]||(t[25]=s=>n.searchQuery=s),placeholder:"Search..."},null,512),[[e.vModelText,n.searchQuery]])])]),e.createElementVNode("table",fi,[t[63]||(t[63]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Equipment"),e.createElementVNode("th",null,"Task Name"),e.createElementVNode("th",null,"Assigned To"),e.createElementVNode("th",null,"Intervals"),e.createElementVNode("th",null,"Remaining"),e.createElementVNode("th",null,"Next Due"),e.createElementVNode("th",null,"Status"),e.createElementVNode("th",null,"Action")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.filteredTasks,s=>(e.openBlock(),e.createElementBlock("tr",{key:s.id},[e.createElementVNode("td",null,e.toDisplayString(s.component),1),e.createElementVNode("td",null,e.toDisplayString(s.taskName),1),e.createElementVNode("td",null,e.toDisplayString(s.assignedTo),1),e.createElementVNode("td",null,e.toDisplayString(s.recurrence),1),e.createElementVNode("td",null,e.toDisplayString(s.remainingDays),1),e.createElementVNode("td",null,e.toDisplayString(s.nextDue),1),e.createElementVNode("td",null,[e.createElementVNode("span",{class:e.normalizeClass(["status-badge",s.status.toLowerCase().replace(" ","-")])},e.toDisplayString(s.status),3)]),e.createElementVNode("td",null,[s.status==="Completed"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:a=>i.printMaintenance(s.component),class:"status-action"},"Print",8,hi)):(e.openBlock(),e.createElementBlock("button",{key:1,onClick:a=>i.showMaintenance(s.component),class:"status-action"},"Start",8,gi))])]))),128))])]),r.tasks.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",yi,[e.createElementVNode("div",Ei,[t[65]||(t[65]=e.createElementVNode("h4",{class:"alert-heading"},"Such Empty!!!",-1)),t[66]||(t[66]=e.createElementVNode("p",null,"You have no maintenance, because you have not scheduled any for this ship.",-1)),t[67]||(t[67]=e.createElementVNode("hr",null,null,-1)),e.createElementVNode("p",Ni,[t[64]||(t[64]=e.createTextVNode("Navigate to the schedule tab, to start scheduling. Or click on this button to ",-1)),e.createElementVNode("button",{type:"button",class:"btn btn-primary",onClick:t[26]||(t[26]=s=>i.switchSchedule())},"Schedule")])])]))])],2),[[e.vShow,n.activeSection==="inventory"]])],512),[[e.vShow,!n.showReport]]),e.withDirectives(e.createElementVNode("div",bi,[t[89]||(t[89]=e.createElementVNode("div",{class:"header"},[e.createElementVNode("div",{class:"report-title"},"MAINTENANCE TASK REPORT")],-1)),e.createElementVNode("div",Vi,[e.createElementVNode("div",ki,[t[69]||(t[69]=e.createElementVNode("div",{class:"info-label"},"Report Generated:",-1)),e.createElementVNode("div",null,e.toDisplayString(n.reportDate),1)]),e.createElementVNode("div",wi,[t[70]||(t[70]=e.createElementVNode("div",{class:"info-label"},"Report ID:",-1)),e.createElementVNode("div",null,e.toDisplayString(n.reportId),1)]),e.createElementVNode("div",Ci,[t[71]||(t[71]=e.createElementVNode("div",{class:"info-label"},"Total Tasks:",-1)),e.createElementVNode("div",null,e.toDisplayString(n.maintenanceTasks.length),1)]),t[72]||(t[72]=e.createElementVNode("div",{class:"info-box"},[e.createElementVNode("div",{class:"info-label"},"Generated By:"),e.createElementVNode("div",null,"OceanHelm System")],-1))]),e.createElementVNode("div",Di,[t[75]||(t[75]=e.createElementVNode("div",{class:"section-title"},"📊 Task Summary",-1)),e.createElementVNode("div",_i,[t[74]||(t[74]=e.createStaticVNode('<div class="summary-card"><div class="summary-number">1</div><div class="summary-label">Completed</div></div><div class="summary-card"><div class="summary-number">0</div><div class="summary-label">Pending</div></div><div class="summary-card"><div class="summary-number">0</div><div class="summary-label">Overdue</div></div>',3)),e.createElementVNode("div",ui,[e.createElementVNode("div",Si,e.toDisplayString(i.totalEstimatedHours),1),t[73]||(t[73]=e.createElementVNode("div",{class:"summary-label"},"Total Hours",-1))])])]),e.createElementVNode("div",Fi,[t[85]||(t[85]=e.createElementVNode("div",{class:"section-title"},"🔧 Maintenance Tasks",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.maintenanceTasks,s=>(e.openBlock(),e.createElementBlock("div",{key:s.taskName,class:e.normalizeClass(["task-item",i.getTaskStatusClass(s)])},[e.createElementVNode("div",Bi,[e.createElementVNode("div",null,[e.createElementVNode("div",xi,[e.createTextVNode(e.toDisplayString(s.taskName)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["maintenance-type","type-"+s.maintenanceType])},e.toDisplayString(s.maintenanceType),3)]),e.createElementVNode("div",Ti,"Component: "+e.toDisplayString(s.component),1)]),e.createElementVNode("span",{class:e.normalizeClass(["status-badge","status-"+s.status.toLowerCase().replace(" ","-")])},e.toDisplayString(s.status),3)]),e.createElementVNode("div",Ri,[e.createElementVNode("div",Ai,[t[76]||(t[76]=e.createElementVNode("div",{class:"detail-label"},"Assigned To",-1)),e.createElementVNode("div",Pi,e.toDisplayString(s.assignedTo),1)]),e.createElementVNode("div",Mi,[t[77]||(t[77]=e.createElementVNode("div",{class:"detail-label"},"Estimated Hours",-1)),e.createElementVNode("div",Ii,e.toDisplayString(s.estimatedHours)+" hours",1)]),e.createElementVNode("div",Li,[t[78]||(t[78]=e.createElementVNode("div",{class:"detail-label"},"Last Performed",-1)),e.createElementVNode("div",qi,e.toDisplayString(i.formatDate(s.lastPerformed)),1)]),e.createElementVNode("div",zi,[t[79]||(t[79]=e.createElementVNode("div",{class:"detail-label"},"Next Due",-1)),e.createElementVNode("div",Oi,e.toDisplayString(i.formatDate(s.nextDue)),1)]),e.createElementVNode("div",Ui,[t[80]||(t[80]=e.createElementVNode("div",{class:"detail-label"},"Recurrence",-1)),e.createElementVNode("div",ji,e.toDisplayString(s.recurrence),1)]),e.createElementVNode("div",Gi,[t[81]||(t[81]=e.createElementVNode("div",{class:"detail-label"},"Remaining Days",-1)),e.createElementVNode("div",Hi,e.toDisplayString(s.remainingDays)+" days",1)])]),s.description?(e.openBlock(),e.createElementBlock("div",Wi,[t[82]||(t[82]=e.createElementVNode("div",{class:"detail-label"},"Description",-1)),e.createElementVNode("div",Qi,e.toDisplayString(s.description),1)])):e.createCommentVNode("",!0),s.notes?(e.openBlock(),e.createElementBlock("div",Ji,[t[83]||(t[83]=e.createElementVNode("div",{class:"detail-label"},"Notes",-1)),e.createElementVNode("div",Yi,e.toDisplayString(s.notes),1)])):e.createCommentVNode("",!0),s.checklistProgress&&s.checklistProgress.length>0?(e.openBlock(),e.createElementBlock("div",Zi,[t[84]||(t[84]=e.createElementVNode("div",{class:"detail-label"},"Checklist Progress",-1)),e.createElementVNode("div",Ki,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:i.getChecklistProgress(s)+"%"})},null,4)]),e.createElementVNode("div",$i,e.toDisplayString(i.getCompletedChecklistItems(s))+" of "+e.toDisplayString(s.checklistProgress.length)+" items completed ("+e.toDisplayString(i.getChecklistProgress(s))+"%) ",1),e.createElementVNode("div",Xi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.checklistProgress,(a,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"checklist-item"},[e.createElementVNode("span",vi,e.toDisplayString(a.completed?"✅":"⭕"),1),e.createElementVNode("span",null,e.toDisplayString(a.text||"Checklist Item "+(c+1)),1)]))),128))])])):e.createCommentVNode("",!0)],2))),128))]),e.createElementVNode("div",el,[t[86]||(t[86]=e.createElementVNode("div",{class:"section-title"},"📋 Recommendations",-1)),e.createElementVNode("div",tl,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.generateRecommendations(),s=>(e.openBlock(),e.createElementBlock("li",{key:s},e.toDisplayString(s),1))),128))])])]),e.createElementVNode("div",ol,[t[88]||(t[88]=e.createElementVNode("div",{class:"signature-box"},[e.createElementVNode("div",null,[e.createElementVNode("strong",null,"Report Generated By")]),e.createElementVNode("div",{style:{"margin-top":"10px",color:"#666"}},"OceanHelm Maintenance System")],-1)),e.createElementVNode("div",sl,[t[87]||(t[87]=e.createElementVNode("div",null,[e.createElementVNode("strong",null,"Date")],-1)),e.createElementVNode("div",nl,e.toDisplayString(n.reportDate),1)])])],512),[[e.vShow,n.showReport]])])])):e.createCommentVNode("",!0)}const I=S(gn,[["render",il]]),Vm="",ll={name:"ActivityLogs",props:{loading:Boolean,searchTerm:String,selectedFilter:String,logs:Array,paginatedLogs:Array,totalActivities:Number,todayActivities:Number,activeUsers:Number,totalPages:Number,currentPage:Number},emits:["update:searchTerm","update:selectedFilter","refresh","download","change-page"],methods:{formatDate(o){return new Date(o).toLocaleString()},getBadgeClass(o){return{login:"badge-login",logout:"badge-logout",create:"badge-create",update:"badge-update",delete:"badge-delete",view:"badge-view"}[o]||"badge-view"}}},rl={class:"activity-logs"},al={class:"a-controls"},dl={class:"a-search-box"},cl=["value"],ml=["value"],pl={class:"stats-grid"},fl={class:"stat-card"},hl={class:"value"},gl={class:"stat-card"},yl={class:"value"},El={class:"stat-card"},Nl={class:"value"},bl={class:"logs-container"},Vl={key:0,class:"loading"},kl={key:1,class:"no-logs"},wl={key:2},Cl={class:"logs-table"},Dl={style:{color:"gray"}},_l={style:{color:"gray"}},ul={class:"pagination"},Sl=["disabled"],Fl=["onClick"],Bl=["disabled"];function xl(o,t,r,l,n,i){return e.openBlock(),e.createElementBlock("div",rl,[e.createElementVNode("div",al,[e.createElementVNode("div",dl,[e.createElementVNode("input",{type:"text",placeholder:"Search activities, users, or actions...",value:r.searchTerm,onInput:t[0]||(t[0]=s=>o.$emit("update:searchTerm",s.target.value))},null,40,cl)]),e.createElementVNode("select",{class:"filter-select",value:r.selectedFilter,onChange:t[1]||(t[1]=s=>o.$emit("update:selectedFilter",s.target.value))},t[6]||(t[6]=[e.createStaticVNode('<option value="all">All Activities</option><option value="login">Login</option><option value="logout">Logout</option><option value="create">Create</option><option value="update">Update</option><option value="delete">Delete</option><option value="view">View</option>',7)]),40,ml),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[2]||(t[2]=s=>o.$emit("refresh"))},"🔄 Refresh"),e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[3]||(t[3]=s=>o.$emit("download"))},"📥 Download Report")]),e.createElementVNode("div",pl,[e.createElementVNode("div",fl,[t[7]||(t[7]=e.createElementVNode("h3",null,"Total Activities",-1)),e.createElementVNode("div",hl,e.toDisplayString(r.totalActivities),1)]),e.createElementVNode("div",gl,[t[8]||(t[8]=e.createElementVNode("h3",null,"Today's Activities",-1)),e.createElementVNode("div",yl,e.toDisplayString(r.todayActivities),1)]),e.createElementVNode("div",El,[t[9]||(t[9]=e.createElementVNode("h3",null,"Active Users",-1)),e.createElementVNode("div",Nl,e.toDisplayString(r.activeUsers),1)]),t[10]||(t[10]=e.createElementVNode("div",{class:"stat-card"},[e.createElementVNode("h3",null,"Important"),e.createElementVNode("div",{class:"badge-danger"}," Logs are deleted at the end of every month, please download a copy ")],-1))]),e.createElementVNode("div",bl,[r.loading?(e.openBlock(),e.createElementBlock("div",Vl,t[11]||(t[11]=[e.createElementVNode("div",{class:"spinner"},null,-1),e.createElementVNode("p",null,"Loading activity logs...",-1)]))):r.logs.length===0?(e.openBlock(),e.createElementBlock("div",kl,t[12]||(t[12]=[e.createElementVNode("h3",null,"No activities found",-1),e.createElementVNode("p",null,"Try adjusting your search or filter criteria",-1)]))):(e.openBlock(),e.createElementBlock("div",wl,[e.createElementVNode("table",Cl,[t[13]||(t[13]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Timestamp"),e.createElementVNode("th",null,"User Name"),e.createElementVNode("th",null,"Action"),e.createElementVNode("th",null,"Details"),e.createElementVNode("th",null,"Section")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.paginatedLogs,s=>(e.openBlock(),e.createElementBlock("tr",{key:s.id},[e.createElementVNode("td",null,e.toDisplayString(i.formatDate(s.timestamp)),1),e.createElementVNode("td",null,[e.createElementVNode("div",null,e.toDisplayString(s.user_name),1),e.createElementVNode("small",Dl,e.toDisplayString(s.email),1)]),e.createElementVNode("td",null,[e.createElementVNode("span",{class:e.normalizeClass(["activity-badge",i.getBadgeClass(s.action)])},e.toDisplayString(s.action),3)]),e.createElementVNode("td",null,[e.createTextVNode(e.toDisplayString(s.details.status)+" ",1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.details.information,(a,c)=>(e.openBlock(),e.createElementBlock("div",{key:c},[e.createElementVNode("strong",null,e.toDisplayString(c)+": ",1),e.createElementVNode("small",_l,e.toDisplayString((a==null?void 0:a.from)??"")+" → "+e.toDisplayString((a==null?void 0:a.to)??a??""),1)]))),128))]),e.createElementVNode("td",null,e.toDisplayString(s.table_name),1)]))),128))])]),e.createElementVNode("div",ul,[e.createElementVNode("button",{onClick:t[4]||(t[4]=s=>o.$emit("change-page",r.currentPage-1)),disabled:r.currentPage===1}," Previous ",8,Sl),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.totalPages,s=>(e.openBlock(),e.createElementBlock("button",{key:s,onClick:a=>o.$emit("change-page",s),class:e.normalizeClass({active:r.currentPage===s})},e.toDisplayString(s),11,Fl))),128)),e.createElementVNode("button",{onClick:t[5]||(t[5]=s=>o.$emit("change-page",r.currentPage+1)),disabled:r.currentPage===r.totalPages}," Next ",8,Bl)])]))])])}const L=S(ll,[["render",xl]]),km="",Tl={name:"CrewManagement",props:{crew:{type:Array,required:!0,default:()=>[]},vesselName:{type:String,default:""},currentCompanyId:{type:String,required:!0,default:""},userProfile:{type:Object,default:()=>({role:"viewer"})},loading:{type:Boolean,default:!1},availableRoles:{type:Array,default:()=>["Captain","First Officer","Engineer","Deckhand","Mechanic","Cook"]},config:{type:Object,default:()=>({showWaveBackground:!0,enableAdd:!0,enableEdit:!0,enableDelete:!0,enableAssignShift:!0,enableCertificationManagement:!0})}},emits:["crew-add","crew-edit","crew-delete","view-pending-certifications","crew-assign-shift","crew-deboard","crew-checkin","crew-add-certification","crew-view-certification","search-changed","filter-changed","access-denied","upload-cert-image","guest-checkin","guest-checkout"],data(){return{searchQuery:"",filterStatus:"all",showAddForm:!1,showGuestForm:!1,formErrors:{},guestFormErrors:{},expandedLogs:[],showTimesheet:!1,timesheetFilter:"all",timesheetSearch:"",timesheetSortKey:"timestamp",timesheetSortOrder:"desc",newCrew:{name:"",role:"Deckhand",customRole:"",status:"available",nextShift:"",certifications:[{name:"",expiryDate:"",imageFile:null,imagePreview:null,imageName:"",imageType:""}],notes:"",email:"",onBoard:""},newGuest:{name:"",email:"",vessel:"",arrivalDate:"",expectedDays:"",notes:""}}},computed:{sectionTitle(){return this.vesselName?`Current Crew for ${this.vesselName}`:"All Fleet Crew"},getApprovedCertifications(){return o=>!o.certifications||o.certifications.length===0?[]:o.certifications.filter(t=>{if(!t.verifications||t.verifications.length===0)return!1;const r=t.verifications.find(l=>l.companyId===this.currentCompanyId);return r&&r.status==="approved"})},filteredCrew(){return this.crew.filter(o=>{const t=this.searchQuery===""||o.name.toLowerCase().includes(this.searchQuery.toLowerCase())||o.role.toLowerCase().includes(this.searchQuery.toLowerCase())||o.vessel&&o.vessel.toLowerCase().includes(this.searchQuery.toLowerCase()),r=this.filterStatus==="all"||o.status===this.filterStatus;return t&&r})},allTimesheetEntries(){const o=[];return this.crew.forEach(t=>{t.log&&t.log.length>0&&t.log.forEach((r,l)=>{o.push({...r,crewName:t.name,role:t.role,crewId:t.id,uniqueId:`${t.id}-${l}`})})}),o.sort((t,r)=>{const l=new Date(t.timestamp),n=new Date(r.timestamp);return this.timesheetSortOrder==="desc"?n-l:l-n})},filteredTimesheetEntries(){let o=this.allTimesheetEntries;if(this.timesheetFilter!=="all"&&(o=o.filter(t=>t.action===this.timesheetFilter)),this.timesheetSearch){const t=this.timesheetSearch.toLowerCase();o=o.filter(r=>r.crewName.toLowerCase().includes(t)||r.role.toLowerCase().includes(t)||r.action.toLowerCase().includes(t)||r.vessel&&r.vessel.toLowerCase().includes(t)||r.notes&&r.notes.toLowerCase().includes(t))}return this.sortTimesheetEntries(o)},uniqueCrewCount(){return new Set(this.filteredTimesheetEntries.map(t=>t.crewId)).size},timesheetDateRange(){if(this.filteredTimesheetEntries.length===0)return"N/A";const o=this.filteredTimesheetEntries.map(n=>new Date(n.timestamp)),t=new Date(Math.min(...o)),r=new Date(Math.max(...o)),l=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return`${l(t)} - ${l(r)}`},canAddCrew(){return this.config.enableAdd&&this.hasPermission("add")},canEditCrew(){return this.config.enableEdit&&this.hasPermission("edit")},canDeleteCrew(){return this.config.enableDelete&&this.hasPermission("delete")},canAssignShift(){return this.config.enableAssignShift&&this.hasPermission("assign")},canDeboardCrew(){return this.config.enableAssignShift&&this.hasPermission("assign")},currentDate(){return new Date().toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})},totalOnboard(){return this.crew.filter(o=>o.status==="onboard").length},crewOnboard(){return this.crew.filter(o=>o.status==="onboard"&&o.role!=="guest").length},guestsOnboard(){return this.crew.filter(o=>o.status==="onboard"&&o.role==="guest").length},personnelByVessel(){const o={};return this.crew.forEach(t=>{t.status==="onboard"&&t.vessel&&(o[t.vessel]||(o[t.vessel]={crew:0,guests:0,total:0}),t.role==="guest"?o[t.vessel].guests++:o[t.vessel].crew++,o[t.vessel].total++)}),o},availableVessels(){const o=new Set;return this.crew.forEach(t=>{t.vessel&&t.vessel.trim()!==""&&o.add(t.vessel)}),Array.from(o).sort()}},methods:{hasPermission(o){const{role:t,vessel:r}=this.userProfile,l=r===this.vesselName;let i={owner:["add","edit","delete","assign","view"],staff:["add","edit","assign","view"],captain:["assign","view"],viewer:["view"]}[t]||[];return t==="captain"&&l&&(i=[...i,"add"]),i.includes(o)},getEmbarkationDate(o){return["onboard","onduty","assigned"].includes(o.status)?o.nextShift||"Not Scheduled":"N/A"},getDaysOnboard(o){if(o.status!=="onboard"||!o.log||o.log.length===0)return"N/A";let t=null;for(let s=o.log.length-1;s>=0;s--)if(o.log[s].action==="Onboard"){t=o.log[s];break}if(!t||!t.timestamp)return"N/A";const r=new Date(t.timestamp),n=Math.abs(new Date-r);return Math.floor(n/(1e3*60*60*24))},getGuestDaysOnboard(o){if(!o.nextShift||o.status!=="onboard")return"N/A";const t=new Date(o.nextShift),l=Math.abs(new Date-t);return Math.floor(l/(1e3*60*60*24))},getPendingCertificationsCount(o){return!o.certifications||o.certifications.length===0?0:o.certifications.filter(t=>{if(!t.verifications||t.verifications.length===0)return!0;const r=t.verifications.find(l=>l.companyId===this.currentCompanyId);return!r||r.status==="pending"}).length},handleViewPendingCertifications(o){this.$emit("view-pending-certifications",{memberId:o.id,memberName:o.name,companyId:this.currentCompanyId})},handleToggleAddForm(){if(!this.canAddCrew){this.$emit("access-denied",{action:"add crew",userProfile:this.userProfile});return}this.showAddForm=!this.showAddForm,this.showAddForm||this.resetForm()},handleToggleGuestForm(){if(!this.canAddCrew){this.$emit("access-denied",{action:"check-in guest",userProfile:this.userProfile});return}this.showGuestForm=!this.showGuestForm,this.showGuestForm||this.resetGuestForm()},handleCheckinGuest(){if(!this.validateGuestForm())return;const o={name:this.newGuest.name,role:"guest",status:"onboard",nextShift:this.newGuest.arrivalDate,onBoard:this.newGuest.expectedDays,email:this.newGuest.email||"",notes:this.newGuest.notes,vessel:this.vesselName||this.newGuest.vessel,certifications:[]};this.$emit("guest-checkin",o),this.resetGuestForm(),this.showGuestForm=!1},handleCheckoutGuest(o){if(!this.canDeboardCrew){this.$emit("access-denied",{action:"check out guest",userProfile:this.userProfile});return}let t=null;if(o.nextShift){const r=new Date(o.nextShift),n=Math.abs(new Date-r);t=Math.ceil(n/(1e3*60*60*24))}this.$emit("guest-checkout",{member:o,duration:t})},handleCancelGuestForm(){this.showGuestForm=!1,this.resetGuestForm()},resetGuestForm(){this.newGuest={name:"",email:"",vessel:"",arrivalDate:"",expectedDays:"",notes:""},this.guestFormErrors={}},validateGuestForm(){return this.guestFormErrors={},(!this.newGuest.name||this.newGuest.name.trim()==="")&&(this.guestFormErrors.name="Guest name is required"),!this.vesselName&&(!this.newGuest.vessel||this.newGuest.vessel.trim()==="")&&(this.guestFormErrors.vessel="Please select a vessel"),this.newGuest.arrivalDate||(this.guestFormErrors.arrivalDate="Arrival date is required"),(!this.newGuest.expectedDays||this.newGuest.expectedDays<=0)&&(this.guestFormErrors.expectedDays="Expected days onboard must be at least 1"),Object.keys(this.guestFormErrors).length>0?(this.$emit("validation-error",this.guestFormErrors),!1):!0},handleSearch(){this.$emit("search-changed",this.searchQuery)},handleFilter(){this.$emit("filter-changed",this.filterStatus)},filterTimesheet(){},sortTimesheet(o){this.timesheetSortKey===o?this.timesheetSortOrder=this.timesheetSortOrder==="asc"?"desc":"asc":(this.timesheetSortKey=o,this.timesheetSortOrder="asc")},sortTimesheetEntries(o){const t=[...o];return t.sort((r,l)=>{let n,i;switch(this.timesheetSortKey){case"timestamp":n=new Date(r.timestamp),i=new Date(l.timestamp);break;case"crewName":n=r.crewName.toLowerCase(),i=l.crewName.toLowerCase();break;case"role":n=r.role.toLowerCase(),i=l.role.toLowerCase();break;case"action":n=r.action.toLowerCase(),i=l.action.toLowerCase();break;default:return 0}return n<i?this.timesheetSortOrder==="asc"?-1:1:n>i?this.timesheetSortOrder==="asc"?1:-1:0}),t},getTimesheetRowClass(o){return`timesheet-row-${o.toLowerCase().replace(/\s+/g,"-")}`},async handleAddCrewMember(){if(!this.validateForm())return;if(this.newCrew.certifications.some(i=>{const s=i.name.trim()!=="",a=i.expiryDate!=="",c=i.imageFile!==null;return(s||a||c)&&!(s&&a&&c)})){this.$emit("incomplete-certification");return}const t=this.newCrew.certifications.filter(i=>i.name.trim()!==""&&i.expiryDate!==""&&i.imageFile!==null),r=this.newCrew.role==="Other"?this.newCrew.customRole:this.newCrew.role,l=await Promise.all(t.map(async(i,s)=>{const a=await this.uploadCertificationImage(i.imageFile,this.newCrew.email);return{name:i.name,expiryDate:i.expiryDate,imageName:i.imageName,imageType:i.imageType,imageUrl:a.publicUrl}})),n={name:this.newCrew.name,role:r,status:"unavailable",certifications:l,notes:this.newCrew.notes,vessel:this.vesselName,email:this.newCrew.email,onBoard:this.newCrew.onBoard,nextShift:this.newCrew.nextShift};this.$emit("crew-add",n),this.resetForm(),this.showAddForm=!1},async uploadCertificationImage(o,t){return new Promise((r,l)=>{this.$emit("upload-cert-image",{file:o,email:t,callback:n=>{n.error?l(n.error):r(n)}})})},handleCancelForm(){this.showAddForm=!1,this.resetForm()},handleDeleteCrew(o){if(!this.canDeleteCrew){this.$emit("access-denied",{action:"delete crew",userProfile:this.userProfile});return}this.$emit("crew-delete",o)},handleAssignShift(o){if(!this.canAssignShift){this.$emit("access-denied",{action:"assign shift",userProfile:this.userProfile});return}this.$emit("crew-assign-shift",o)},handleDeboardCrew(o){if(!this.canDeboardCrew){this.$emit("access-denied",{action:"deboard crew",userProfile:this.userProfile});return}let t=null;if(o.nextShift){const r=new Date(o.nextShift),n=Math.abs(new Date-r);t=Math.ceil(n/(1e3*60*60*24))}this.$emit("crew-deboard",{member:o,duration:t})},handleCheckinCrew(o){if(!this.canDeboardCrew){this.$emit("access-denied",{action:"check in crew",userProfile:this.userProfile});return}this.$emit("crew-checkin",o)},toggleCrewLog(o){const t=this.expandedLogs.indexOf(o);t>-1?this.expandedLogs.splice(t,1):this.expandedLogs.push(o)},handleAddCertification(o){if(!this.canEditCrew){this.$emit("access-denied",{action:"add certification",userProfile:this.userProfile});return}this.$emit("crew-add-certification",o)},handleViewCertification(o,t){this.$emit("crew-view-certification",{certification:o,member:t})},resetForm(){this.newCrew={name:"",role:"Deckhand",customRole:"",status:"Unavailable",nextShift:"",certifications:[{name:"",expiryDate:"",imageFile:null,imagePreview:null,imageName:"",imageType:""}],notes:"",email:"",onBoard:""},this.formErrors={}},validateForm(){this.formErrors={};const o={name:"Full Name",email:"Email Address"};return Object.keys(o).forEach(t=>{(!this.newCrew[t]||this.newCrew[t].trim()==="")&&(this.formErrors[t]=`${o[t]} is required`)}),this.newCrew.email&&!this.isValidEmail(this.newCrew.email)&&(this.formErrors.email="Please enter a valid email address"),this.newCrew.role==="Other"&&(!this.newCrew.customRole||this.newCrew.customRole.trim()==="")&&(this.formErrors.customRole='Custom role is required when "Other" is selected'),Object.keys(this.formErrors).length>0?(this.$emit("validation-error",this.formErrors),!1):!0},isValidEmail(o){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)},addCertificationEntry(){this.newCrew.certifications.push({name:"",expiryDate:"",imageFile:null,imagePreview:null,imageName:"",imageType:""})},removeCertification(o){this.newCrew.certifications.splice(o,1)},handleCertImageUpload(o,t){const r=o.target.files[0];if(!r)return;const l=this.newCrew.certifications[t];if(l.imageFile=r,l.imageName=r.name,l.imageType=r.type.includes("pdf")?"pdf":"image",l.imageType==="image"){const n=new FileReader;n.onload=i=>{l.imagePreview=i.target.result},n.readAsDataURL(r)}else l.imagePreview="pdf"},removeCertImage(o){const t=this.newCrew.certifications[o];t.imageFile=null,t.imagePreview=null,t.imageName="",t.imageType="";const r=document.getElementById("cert-image-"+o);r&&(r.value="")},formatStatus(o){return o?o.charAt(0).toUpperCase()+o.slice(1):""},getStatusClass(o){return{available:"status-available",onduty:"status-onduty",onboard:"status-onboard",unavailable:"status-unavailable",assigned:"status-assigned"}[o]||""},getCertificationClass(o){const t=this.getExpiryStatus(o);return{expired:"text-danger",expiringSoon:"text-warning",valid:"text-success"}[t]||""},getExpiryStatus(o){if(!o)return"none";const t=new Date(o),r=new Date,l=new Date;return l.setMonth(r.getMonth()+1),t<=r?"expired":t<=l?"expiringSoon":"valid"},formatLogDate(o){return o?new Date(o).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""},getLogActionClass(o){return{Embarked:"log-action-embark",Deboarded:"log-action-deboard",Assigned:"log-action-assign","Status Changed":"log-action-status"}[o]||""},getLogIcon(o){return{Embarked:"bi bi-box-arrow-in-right",Deboarded:"bi bi-box-arrow-left",Assigned:"bi bi-calendar-check","Status Changed":"bi bi-arrow-repeat"}[o]||"bi bi-circle-fill"}}},Rl={class:"crew-management"},Al={key:0,class:"wave-bg"},Pl={class:"crew-section"},Ml={class:"crew-section-header"},Il={class:"crew-subhead"},Ll={class:"header-actions"},ql={key:0,class:"personnel-summary"},zl={class:"summary-header"},Ol={class:"summary-date"},Ul={class:"summary-cards"},jl={class:"summary-card total-card"},Gl={class:"card-content"},Hl={class:"card-value"},Wl={class:"summary-card crew-card"},Ql={class:"card-content"},Jl={class:"card-value"},Yl={class:"summary-card guest-card-summary"},Zl={class:"card-content"},Kl={class:"card-value"},$l={key:0,class:"vessel-breakdown"},Xl={class:"vessel-cards"},vl={class:"vessel-name"},er={class:"vessel-stats"},tr={class:"stat-item"},or={class:"stat-value"},sr={class:"stat-item"},nr={class:"stat-value"},ir={class:"stat-item total-stat"},lr={class:"stat-value"},rr={key:1,class:"search-filter"},ar={key:2,class:"loading-state"},dr={key:3,class:"timesheet-view"},cr={class:"timesheet-header"},mr={class:"timesheet-controls"},pr={class:"timesheet-summary"},fr={class:"summary-card"},hr={class:"summary-value"},gr={class:"summary-card"},yr={class:"summary-value"},Er={class:"summary-card"},Nr={class:"summary-value"},br={key:0,class:"no-results"},Vr={key:1,class:"timesheet-table-container"},kr={class:"timesheet-table"},wr={class:"timestamp-cell"},Cr={class:"crew-name-cell"},Dr={class:"role-cell"},_r={class:"action-cell"},ur={class:"vessel-cell"},Sr={class:"duration-cell"},Fr={class:"notes-cell"},Br={key:4,class:"crew-grid"},xr={class:"crew-name"},Tr={class:"crew-role"},Rr={key:0,class:"crew-certifications"},Ar=["onClick"],Pr={key:0,class:"certification-tag text-muted"},Mr=["onClick"],Ir={key:1},Lr={class:"crew-availability"},qr={class:"crew-availability"},zr={class:"crew-availability"},Or={key:2},Ur={class:"crew-availability"},jr={class:"crew-availability"},Gr={class:"crew-availability"},Hr={class:"action-buttons"},Wr={key:0,class:"status-available crew-availability vcard"},Qr={key:1,class:"status-unavailable crew-availability vcard"},Jr=["onClick"],Yr=["onClick"],Zr=["onClick"],Kr=["onClick"],$r={class:"crew-footer"},Xr={key:0,class:"crew-log-toggle"},vr=["onClick"],ea=["onClick"],ta={key:3,class:"crew-log"},oa={class:"log-date"},sa={class:"log-details"},na={key:0},ia={key:1},la={key:0,class:"log-notes"},ra={key:5,class:"no-results"},aa={key:6,class:"add-crew-form"},da={class:"form-row"},ca={class:"form-group"},ma={key:0,class:"error-message"},pa={class:"form-group"},fa=["value"],ha={class:"form-row"},ga={class:"form-group"},ya={key:0,class:"error-message"},Ea={class:"form-row"},Na={class:"form-group"},ba={class:"form-actions"},Va={key:7,class:"add-crew-form"},ka={class:"form-row"},wa={class:"form-group"},Ca={key:0,class:"error-message"},Da={class:"form-group"},_a={key:0,class:"form-row"},ua={class:"form-group"},Sa=["value"],Fa={key:0,class:"error-message"},Ba={class:"form-row"},xa={class:"form-group"},Ta={key:0,class:"error-message"},Ra={class:"form-group"},Aa={key:0,class:"error-message"},Pa={class:"form-row"},Ma={class:"form-group"},Ia={class:"form-actions"};function La(o,t,r,l,n,i){return e.openBlock(),e.createElementBlock("div",Rl,[r.config.showWaveBackground?(e.openBlock(),e.createElementBlock("div",Al)):e.createCommentVNode("",!0),e.createElementVNode("div",Pl,[e.createElementVNode("div",Ml,[e.createElementVNode("h4",Il,e.toDisplayString(i.sectionTitle),1),e.createElementVNode("div",Ll,[i.canAddCrew?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-secondary",onClick:t[0]||(t[0]=(...s)=>i.handleToggleGuestForm&&i.handleToggleGuestForm(...s))},e.toDisplayString(n.showGuestForm?"Cancel":"+ Check-in Guest"),1)):e.createCommentVNode("",!0),i.canAddCrew?(e.openBlock(),e.createElementBlock("button",{key:1,class:"btn btn-primary",onClick:t[1]||(t[1]=(...s)=>i.handleToggleAddForm&&i.handleToggleAddForm(...s))},e.toDisplayString(n.showAddForm?"Cancel":"+ Add Crew Member"),1)):e.createCommentVNode("",!0)])]),!n.showAddForm&&!n.showGuestForm&&!n.showTimesheet?(e.openBlock(),e.createElementBlock("div",ql,[e.createElementVNode("div",zl,[t[29]||(t[29]=e.createElementVNode("h3",null,[e.createElementVNode("i",{class:"bi bi-people-fill"}),e.createTextVNode(" Personnel Onboard Summary")],-1)),e.createElementVNode("div",Ol,e.toDisplayString(i.currentDate),1)]),e.createElementVNode("div",Ul,[e.createElementVNode("div",jl,[t[31]||(t[31]=e.createElementVNode("div",{class:"card-icon"},[e.createElementVNode("i",{class:"bi bi-people"})],-1)),e.createElementVNode("div",Gl,[e.createElementVNode("div",Hl,e.toDisplayString(i.totalOnboard),1),t[30]||(t[30]=e.createElementVNode("div",{class:"card-label"},"Total Onboard",-1))])]),e.createElementVNode("div",Wl,[t[33]||(t[33]=e.createElementVNode("div",{class:"card-icon"},[e.createElementVNode("i",{class:"bi bi-person-badge"})],-1)),e.createElementVNode("div",Ql,[e.createElementVNode("div",Jl,e.toDisplayString(i.crewOnboard),1),t[32]||(t[32]=e.createElementVNode("div",{class:"card-label"},"Crew Onboard",-1))])]),e.createElementVNode("div",Yl,[t[35]||(t[35]=e.createElementVNode("div",{class:"card-icon"},[e.createElementVNode("i",{class:"bi bi-person-check"})],-1)),e.createElementVNode("div",Zl,[e.createElementVNode("div",Kl,e.toDisplayString(i.guestsOnboard),1),t[34]||(t[34]=e.createElementVNode("div",{class:"card-label"},"Guests Onboard",-1))])])]),Object.keys(i.personnelByVessel).length>0?(e.openBlock(),e.createElementBlock("div",$l,[t[39]||(t[39]=e.createElementVNode("h4",null,"Breakdown by Vessel",-1)),e.createElementVNode("div",Xl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.personnelByVessel,(s,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,class:"vessel-card"},[e.createElementVNode("div",vl,e.toDisplayString(a),1),e.createElementVNode("div",er,[e.createElementVNode("div",tr,[t[36]||(t[36]=e.createElementVNode("span",{class:"stat-label"},"Crew:",-1)),e.createElementVNode("span",or,e.toDisplayString(s.crew),1)]),e.createElementVNode("div",sr,[t[37]||(t[37]=e.createElementVNode("span",{class:"stat-label"},"Guests:",-1)),e.createElementVNode("span",nr,e.toDisplayString(s.guests),1)]),e.createElementVNode("div",ir,[t[38]||(t[38]=e.createElementVNode("span",{class:"stat-label"},"Total:",-1)),e.createElementVNode("span",lr,e.toDisplayString(s.total),1)])])]))),128))])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!n.showAddForm&&!n.showGuestForm?(e.openBlock(),e.createElementBlock("div",rr,[e.withDirectives(e.createElementVNode("input",{type:"text",placeholder:"Search crew by name or role...","onUpdate:modelValue":t[2]||(t[2]=s=>n.searchQuery=s),onInput:t[3]||(t[3]=(...s)=>i.handleSearch&&i.handleSearch(...s))},null,544),[[e.vModelText,n.searchQuery]]),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[4]||(t[4]=s=>n.filterStatus=s),onChange:t[5]||(t[5]=(...s)=>i.handleFilter&&i.handleFilter(...s))},t[40]||(t[40]=[e.createStaticVNode('<option value="all">All Statuses</option><option value="available">Available</option><option value="onduty">On Duty</option><option value="onboard">On Board</option><option value="assigned">Assigned</option><option value="unavailable">Unavailable</option>',6)]),544),[[e.vModelSelect,n.filterStatus]]),e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[6]||(t[6]=s=>n.showTimesheet=!n.showTimesheet)},[e.createElementVNode("i",{class:e.normalizeClass(n.showTimesheet?"bi bi-grid-3x3-gap":"bi bi-table")},null,2),e.createTextVNode(" "+e.toDisplayString(n.showTimesheet?"Show Crew Cards":"Show Timesheet"),1)])])):e.createCommentVNode("",!0),r.loading&&!n.showAddForm&&!n.showGuestForm?(e.openBlock(),e.createElementBlock("div",ar,t[41]||(t[41]=[e.createElementVNode("div",{class:"spinner-border text-primary",role:"status"},[e.createElementVNode("span",{class:"visually-hidden"},"Loading crew...")],-1),e.createElementVNode("p",null,"Loading crew members...",-1)]))):n.showTimesheet&&!n.showAddForm&&!n.showGuestForm?(e.openBlock(),e.createElementBlock("div",dr,[e.createElementVNode("div",cr,[t[43]||(t[43]=e.createElementVNode("h3",null,[e.createElementVNode("i",{class:"bi bi-table"}),e.createTextVNode(" Crew Activity Timesheet")],-1)),e.createElementVNode("div",mr,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[7]||(t[7]=s=>n.timesheetFilter=s),onChange:t[8]||(t[8]=(...s)=>i.filterTimesheet&&i.filterTimesheet(...s))},t[42]||(t[42]=[e.createStaticVNode('<option value="all">All Activities</option><option value="Embarked">Embarked Only</option><option value="Deboarded">Deboarded Only</option><option value="Assigned">Assigned Only</option><option value="Status Changed">Status Changes Only</option>',5)]),544),[[e.vModelSelect,n.timesheetFilter]]),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":t[9]||(t[9]=s=>n.timesheetSearch=s),placeholder:"Search timesheet...",class:"timesheet-search"},null,512),[[e.vModelText,n.timesheetSearch]])])]),e.createElementVNode("div",pr,[e.createElementVNode("div",fr,[t[44]||(t[44]=e.createElementVNode("span",{class:"summary-label"},"Total Entries:",-1)),e.createElementVNode("span",hr,e.toDisplayString(i.filteredTimesheetEntries.length),1)]),e.createElementVNode("div",gr,[t[45]||(t[45]=e.createElementVNode("span",{class:"summary-label"},"Crew Members:",-1)),e.createElementVNode("span",yr,e.toDisplayString(i.uniqueCrewCount),1)]),e.createElementVNode("div",Er,[t[46]||(t[46]=e.createElementVNode("span",{class:"summary-label"},"Date Range:",-1)),e.createElementVNode("span",Nr,e.toDisplayString(i.timesheetDateRange),1)])]),i.filteredTimesheetEntries.length===0?(e.openBlock(),e.createElementBlock("div",br," No timesheet entries found. ")):(e.openBlock(),e.createElementBlock("div",Vr,[e.createElementVNode("table",kr,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",{onClick:t[10]||(t[10]=s=>i.sortTimesheet("timestamp"))},t[47]||(t[47]=[e.createTextVNode(" Date/Time ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),e.createElementVNode("th",{onClick:t[11]||(t[11]=s=>i.sortTimesheet("crewName"))},t[48]||(t[48]=[e.createTextVNode(" Crew Member ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),e.createElementVNode("th",{onClick:t[12]||(t[12]=s=>i.sortTimesheet("role"))},t[49]||(t[49]=[e.createTextVNode(" Role ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),e.createElementVNode("th",{onClick:t[13]||(t[13]=s=>i.sortTimesheet("action"))},t[50]||(t[50]=[e.createTextVNode(" Action ",-1),e.createElementVNode("i",{class:"bi bi-arrow-down-up"},null,-1)])),t[51]||(t[51]=e.createElementVNode("th",null,"Vessel",-1)),t[52]||(t[52]=e.createElementVNode("th",null,"Duration",-1)),t[53]||(t[53]=e.createElementVNode("th",null,"Notes",-1))])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.filteredTimesheetEntries,s=>(e.openBlock(),e.createElementBlock("tr",{key:s.uniqueId,class:e.normalizeClass(i.getTimesheetRowClass(s.action))},[e.createElementVNode("td",wr,e.toDisplayString(i.formatLogDate(s.timestamp)),1),e.createElementVNode("td",Cr,[e.createElementVNode("strong",null,e.toDisplayString(s.crewName),1)]),e.createElementVNode("td",Dr,e.toDisplayString(s.role),1),e.createElementVNode("td",_r,[e.createElementVNode("span",{class:e.normalizeClass(["action-badge",i.getLogActionClass(s.action)])},[e.createElementVNode("i",{class:e.normalizeClass(i.getLogIcon(s.action))},null,2),e.createTextVNode(" "+e.toDisplayString(s.action),1)],2)]),e.createElementVNode("td",ur,e.toDisplayString(s.vessel||"N/A"),1),e.createElementVNode("td",Sr,e.toDisplayString(s.duration?s.duration+" days":"N/A"),1),e.createElementVNode("td",Fr,e.toDisplayString(s.notes||"-"),1)],2))),128))])])]))])):i.filteredCrew.length>0&&!n.showAddForm&&!n.showGuestForm?(e.openBlock(),e.createElementBlock("div",Br,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.filteredCrew,s=>(e.openBlock(),e.createElementBlock("div",{key:s.id,class:e.normalizeClass(["crew-card",{unavailable:s.status==="unavailable","guest-card":s.role==="guest"}])},[e.createElementVNode("div",{class:e.normalizeClass(["crew-status-badge",i.getStatusClass(s.status)])},e.toDisplayString(i.formatStatus(s.status)),3),e.createElementVNode("div",xr,e.toDisplayString(s.name),1),e.createElementVNode("div",Tr,e.toDisplayString(s.role==="guest"?"Guest":s.role),1),s.role!=="guest"?(e.openBlock(),e.createElementBlock("div",Rr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.getApprovedCertifications(s),a=>(e.openBlock(),e.createElementBlock("div",{key:a.name,class:e.normalizeClass(["certification-tag",i.getCertificationClass(a.expiryDate)]),onClick:c=>i.handleViewCertification(a,s)},e.toDisplayString(a.name),11,Ar))),128)),i.getPendingCertificationsCount(s)>0?(e.openBlock(),e.createElementBlock("div",Pr,[t[54]||(t[54]=e.createElementVNode("i",{class:"bi bi-clock-history"},null,-1)),e.createTextVNode(" "+e.toDisplayString(i.getPendingCertificationsCount(s))+" pending ",1)])):e.createCommentVNode("",!0),i.canEditCrew?(e.openBlock(),e.createElementBlock("i",{key:1,class:"bi bi-patch-plus-fill icon",onClick:a=>i.handleAddCertification(s)},null,8,Mr)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),s.role==="guest"?(e.openBlock(),e.createElementBlock("div",Ir,[e.createElementVNode("div",Lr,[t[55]||(t[55]=e.createElementVNode("strong",null,"Arrival Date:",-1)),e.createTextVNode(" "+e.toDisplayString(s.nextShift||"Not Recorded"),1)]),e.createElementVNode("div",qr,[t[56]||(t[56]=e.createElementVNode("strong",null,"Expected Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(s.onBoard||"Not Specified"),1)]),e.createElementVNode("div",zr,[t[57]||(t[57]=e.createElementVNode("strong",null,"Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(i.getGuestDaysOnboard(s)),1)])])):(e.openBlock(),e.createElementBlock("div",Or,[e.createElementVNode("div",Ur,[t[58]||(t[58]=e.createElementVNode("strong",null,"Embarkation Date:",-1)),e.createTextVNode(" "+e.toDisplayString(i.getEmbarkationDate(s)),1)]),e.createElementVNode("div",jr,[t[59]||(t[59]=e.createElementVNode("strong",null,"Expected Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(s.onBoard||"Not Scheduled"),1)]),e.createElementVNode("div",Gr,[t[60]||(t[60]=e.createElementVNode("strong",null,"Days Onboard:",-1)),e.createTextVNode(" "+e.toDisplayString(i.getDaysOnboard(s)),1)])])),e.createElementVNode("div",Hr,[s.vessel?(e.openBlock(),e.createElementBlock("div",Wr," Vessel: "+e.toDisplayString(s.vessel),1)):(e.openBlock(),e.createElementBlock("div",Qr," Vessel: Unassigned ")),s.role==="guest"&&s.status==="onboard"?(e.openBlock(),e.createElementBlock("button",{key:2,class:"btn btn-warning",onClick:a=>i.handleCheckoutGuest(s)}," Check Out ",8,Jr)):e.createCommentVNode("",!0),s.role!=="guest"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[i.canAssignShift&&s.status==="available"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn btn-primary",onClick:a=>i.handleAssignShift(s)}," Assign Shift ",8,Yr)):e.createCommentVNode("",!0),i.canDeboardCrew&&s.status==="onduty"?(e.openBlock(),e.createElementBlock("button",{key:1,class:"btn btn-success",onClick:a=>i.handleCheckinCrew(s)}," Check In ",8,Zr)):e.createCommentVNode("",!0),i.canDeboardCrew&&s.status==="onboard"?(e.openBlock(),e.createElementBlock("button",{key:2,class:"btn btn-warning",onClick:a=>i.handleDeboardCrew(s)}," Deboard ",8,Kr)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)]),e.createElementVNode("div",$r,[s.log&&s.log.length>0?(e.openBlock(),e.createElementBlock("div",Xr,[e.createElementVNode("button",{class:"btn btn-link btn-sm log-toggle-btn",onClick:a=>i.toggleCrewLog(s.id)},[t[61]||(t[61]=e.createElementVNode("i",{class:"bi bi-clock-history"},null,-1)),e.createTextVNode(" View Log ("+e.toDisplayString(s.log.length)+") ",1)],8,vr)])):e.createCommentVNode("",!0),i.canDeleteCrew?(e.openBlock(),e.createElementBlock("i",{key:1,class:"bi bi-trash icon delete-icon",onClick:a=>i.handleDeleteCrew(s)},null,8,ea)):e.createCommentVNode("",!0)]),n.expandedLogs.includes(s.id)?(e.openBlock(),e.createElementBlock("div",ta,[t[62]||(t[62]=e.createElementVNode("h4",null,"Crew Activity Log",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.log,(a,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"log-entry"},[e.createElementVNode("div",oa,e.toDisplayString(i.formatLogDate(a.timestamp)),1),e.createElementVNode("div",{class:e.normalizeClass(["log-action",i.getLogActionClass(a.action)])},[e.createElementVNode("i",{class:e.normalizeClass(i.getLogIcon(a.action))},null,2),e.createTextVNode(" "+e.toDisplayString(a.action),1)],2),e.createElementVNode("div",sa,[a.vessel?(e.openBlock(),e.createElementBlock("span",na,"Vessel: "+e.toDisplayString(a.vessel),1)):e.createCommentVNode("",!0),a.duration?(e.openBlock(),e.createElementBlock("span",ia," | Duration: "+e.toDisplayString(a.duration)+" days",1)):e.createCommentVNode("",!0)]),a.notes?(e.openBlock(),e.createElementBlock("div",la,e.toDisplayString(a.notes),1)):e.createCommentVNode("",!0)]))),128))])):e.createCommentVNode("",!0)],2))),128))])):!r.loading&&!n.showTimesheet&&!n.showAddForm&&!n.showGuestForm?(e.openBlock(),e.createElementBlock("div",ra,e.toDisplayString(r.crew.length===0?"No crew members found.":"No crew members found matching your search criteria."),1)):e.createCommentVNode("",!0),n.showAddForm?(e.openBlock(),e.createElementBlock("div",aa,[t[68]||(t[68]=e.createElementVNode("h2",null,"Add New Crew Member",-1)),e.createElementVNode("div",da,[e.createElementVNode("div",ca,[t[63]||(t[63]=e.createElementVNode("label",{for:"crew-name"},"Full Name *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"crew-name","onUpdate:modelValue":t[14]||(t[14]=s=>n.newCrew.name=s),class:e.normalizeClass({error:n.formErrors.name})},null,2),[[e.vModelText,n.newCrew.name]]),n.formErrors.name?(e.openBlock(),e.createElementBlock("div",ma,e.toDisplayString(n.formErrors.name),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",pa,[t[65]||(t[65]=e.createElementVNode("label",{for:"crew-role"},"Role/Position *",-1)),e.withDirectives(e.createElementVNode("select",{id:"crew-role","onUpdate:modelValue":t[15]||(t[15]=s=>n.newCrew.role=s)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.availableRoles,s=>(e.openBlock(),e.createElementBlock("option",{key:s,value:s},e.toDisplayString(s),9,fa))),128)),t[64]||(t[64]=e.createElementVNode("option",{value:"Other"},"Other",-1))],512),[[e.vModelSelect,n.newCrew.role]]),n.newCrew.role==="Other"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,type:"text",placeholder:"Enter custom role","onUpdate:modelValue":t[16]||(t[16]=s=>n.newCrew.customRole=s),style:{"margin-top":"8px"}},null,512)),[[e.vModelText,n.newCrew.customRole]]):e.createCommentVNode("",!0)])]),e.createElementVNode("div",ha,[e.createElementVNode("div",ga,[t[66]||(t[66]=e.createElementVNode("label",{for:"crew-email"},"Email Address *",-1)),e.withDirectives(e.createElementVNode("input",{type:"email",id:"crew-email","onUpdate:modelValue":t[17]||(t[17]=s=>n.newCrew.email=s),class:e.normalizeClass({error:n.formErrors.email})},null,2),[[e.vModelText,n.newCrew.email]]),n.formErrors.email?(e.openBlock(),e.createElementBlock("div",ya,e.toDisplayString(n.formErrors.email),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Ea,[e.createElementVNode("div",Na,[t[67]||(t[67]=e.createElementVNode("label",{for:"crew-notes"},"Notes",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"crew-notes",rows:"3","onUpdate:modelValue":t[18]||(t[18]=s=>n.newCrew.notes=s)},null,512),[[e.vModelText,n.newCrew.notes]])])]),e.createElementVNode("div",ba,[e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[19]||(t[19]=(...s)=>i.handleCancelForm&&i.handleCancelForm(...s))},"Cancel"),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[20]||(t[20]=(...s)=>i.handleAddCrewMember&&i.handleAddCrewMember(...s))},"Add Crew Member")])])):e.createCommentVNode("",!0),n.showGuestForm?(e.openBlock(),e.createElementBlock("div",Va,[t[76]||(t[76]=e.createElementVNode("h2",null,"Check-in Guest",-1)),e.createElementVNode("div",ka,[e.createElementVNode("div",wa,[t[69]||(t[69]=e.createElementVNode("label",{for:"guest-name"},"Full Name *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text",id:"guest-name","onUpdate:modelValue":t[21]||(t[21]=s=>n.newGuest.name=s),class:e.normalizeClass({error:n.guestFormErrors.name})},null,2),[[e.vModelText,n.newGuest.name]]),n.guestFormErrors.name?(e.openBlock(),e.createElementBlock("div",Ca,e.toDisplayString(n.guestFormErrors.name),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Da,[t[70]||(t[70]=e.createElementVNode("label",{for:"guest-email"},"Email Address",-1)),e.withDirectives(e.createElementVNode("input",{type:"email",id:"guest-email","onUpdate:modelValue":t[22]||(t[22]=s=>n.newGuest.email=s)},null,512),[[e.vModelText,n.newGuest.email]])])]),r.vesselName?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_a,[e.createElementVNode("div",ua,[t[72]||(t[72]=e.createElementVNode("label",{for:"guest-vessel"},"Vessel *",-1)),e.withDirectives(e.createElementVNode("select",{id:"guest-vessel","onUpdate:modelValue":t[23]||(t[23]=s=>n.newGuest.vessel=s),class:e.normalizeClass({error:n.guestFormErrors.vessel})},[t[71]||(t[71]=e.createElementVNode("option",{value:""},"Select a vessel",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.availableVessels,s=>(e.openBlock(),e.createElementBlock("option",{key:s,value:s},e.toDisplayString(s),9,Sa))),128))],2),[[e.vModelSelect,n.newGuest.vessel]]),n.guestFormErrors.vessel?(e.openBlock(),e.createElementBlock("div",Fa,e.toDisplayString(n.guestFormErrors.vessel),1)):e.createCommentVNode("",!0)])])),e.createElementVNode("div",Ba,[e.createElementVNode("div",xa,[t[73]||(t[73]=e.createElementVNode("label",{for:"guest-arrival"},"Arrival Date *",-1)),e.withDirectives(e.createElementVNode("input",{type:"date",id:"guest-arrival","onUpdate:modelValue":t[24]||(t[24]=s=>n.newGuest.arrivalDate=s),class:e.normalizeClass({error:n.guestFormErrors.arrivalDate})},null,2),[[e.vModelText,n.newGuest.arrivalDate]]),n.guestFormErrors.arrivalDate?(e.openBlock(),e.createElementBlock("div",Ta,e.toDisplayString(n.guestFormErrors.arrivalDate),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Ra,[t[74]||(t[74]=e.createElementVNode("label",{for:"guest-expected-days"},"Expected Days Onboard *",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",id:"guest-expected-days","onUpdate:modelValue":t[25]||(t[25]=s=>n.newGuest.expectedDays=s),min:"1",class:e.normalizeClass({error:n.guestFormErrors.expectedDays})},null,2),[[e.vModelText,n.newGuest.expectedDays]]),n.guestFormErrors.expectedDays?(e.openBlock(),e.createElementBlock("div",Aa,e.toDisplayString(n.guestFormErrors.expectedDays),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Pa,[e.createElementVNode("div",Ma,[t[75]||(t[75]=e.createElementVNode("label",{for:"guest-notes"},"Notes",-1)),e.withDirectives(e.createElementVNode("textarea",{id:"guest-notes",rows:"3","onUpdate:modelValue":t[26]||(t[26]=s=>n.newGuest.notes=s),placeholder:"Purpose of visit, company affiliation, etc."},null,512),[[e.vModelText,n.newGuest.notes]])])]),e.createElementVNode("div",Ia,[e.createElementVNode("button",{class:"btn btn-secondary",onClick:t[27]||(t[27]=(...s)=>i.handleCancelGuestForm&&i.handleCancelGuestForm(...s))},"Cancel"),e.createElementVNode("button",{class:"btn btn-primary",onClick:t[28]||(t[28]=(...s)=>i.handleCheckinGuest&&i.handleCheckinGuest(...s))},"Check-in Guest")])])):e.createCommentVNode("",!0)])])}const q=S(Tl,[["render",La]]),wm="",qa={name:"RequisitionSystem",props:{userProfile:{type:Object,required:!0},userRole:{type:String,required:!0},requisitions:{type:Array,default:()=>[]},vessels:{type:Array,default:()=>[]}},emits:["submit-requisition","submit-info-response","approve-requisition","decline-requisition","info-requisition","create-po","open-po","finish-po","accept-delivery"],data(){return{activeTab:"workflow",isPrinting:!1,infoResponse:"",isSubmitting:!1,tabs:[{name:"new-requisition",label:"New Requisition",roles:["requisitor"]},{name:"my-requisitions",label:"My Requisitions",roles:["requisitor"]},{name:"all-requisitions",label:"All Requisitions",roles:["requisitor","supervisor","captain","owner","purchaser"]},{name:"approvals",label:"Pending Approvals",roles:["owner","supervisor"]},{name:"purchasing",label:"Purchasing Queue",roles:["purchaser"]},{name:"receiving",label:"Receiving",roles:["requisitor"]},{name:"workflow",label:"Workflow Guide",roles:["requisitor","supervisor","owner","purchaser","captain"]}],form:{requestor:"",department:"",project:"",neededDate:"",justification:"",items:[]},poDetails:{editing:!1,items:[]},vendorInfo:{},justificationText:"",currentItemIndex:null,showJustificationModal:!1,requisitionFields:[{label:"Requestor",value:o=>o.requestor},{label:"Department",value:o=>o.department},{label:"Project",value:o=>o.project||"N/A"},{label:"Submitted",value:o=>o.submittedDate},{label:"Items",value:o=>{var t;return`${((t=o.items)==null?void 0:t.length)||0} item(s)`}}],requisitionFieldsMap:{approved:[{label:"Approved By",value:o=>o.approvedBy}],declined:[{label:"Declined By",value:o=>o.declinedBy},{label:"Rejection Reason",value:o=>o.rejectionReason}],"info-requested":[{label:"Info Requester",value:o=>o.infoRequestedBy},{label:"Requested Info",value:o=>o.requestedInfo}]},departments:["Marine Operations","Engineering","Maintenance","Safety & Compliance","Logistics","Administration","Engine Room"],priorities:["Urgent - Same Day","High - Within 3 Days","Normal - Within 1 Week","Low - Within 2 Weeks"],units:["Pieces","Kilograms","Liters","Meters","Sets","Boxes"]}},computed:{today(){return new Date().toISOString().split("T")[0]},visibleTabs(){return this.tabs.filter(o=>o.roles.includes(this.userRole))},subTotal(){return(this.poDetails.items||[]).reduce((o,t)=>{const r=t.unitPrice||t.cost||0;return o+r*(t.qty||0)},0)},grandTotal(){return this.subTotal+this.calculateTax()+parseFloat(this.getOptional(this.vendorInfo.shipping))},reviewRequisitions(){return(this.requisitions||[]).filter(o=>o.status==="under-review")},poRequisitions(){return(this.requisitions||[]).filter(o=>o.status==="approved")},awaitingDelivery(){return(this.requisitions||[]).filter(o=>o.status==="po-created")},currentItem(){return this.currentItemIndex!==null?this.poDetails.items[this.currentItemIndex]:null},myRequisitions(){var t,r;const o=((t=this.userProfile)==null?void 0:t.id)||((r=this.userProfile)==null?void 0:r.profile_id);return(this.requisitions||[]).filter(l=>l.profile_id==o)}},methods:{setActiveTab(o){this.activeTab=o},formatDate(o){return o?new Date(o).toLocaleDateString():"N/A"},calculateTax(){var t;const o=parseFloat(this.vendorInfo.tax||((t=this.poDetails.vendorInfo)==null?void 0:t.tax)||0);return this.subTotal*o/100},getOptional(o){return typeof o=="number"?o.toFixed(2):(parseFloat(o)||0).toFixed(2)},getRequisitionFields(o){const t=this.requisitionFieldsMap[o.status]||[];return[...this.requisitionFields||[],...t]},addItem(){this.form.items.push({id:"",desc:"",qty:1,unit:"Pieces",cost:0})},removeItem(o){this.form.items.splice(o,1)},startEdit(o){this.poDetails.items[o].editing=!0,this.poDetails.items[o].tempPrice=this.poDetails.items[o].unitPrice||this.poDetails.items[o].cost},cancelEdit(o){this.poDetails.items[o].editing=!1,this.poDetails.items[o].tempPrice=this.poDetails.items[o].unitPrice||this.poDetails.items[o].cost},savePrice(o){const t=this.poDetails.items[o];t.tempPrice!==t.cost?(this.currentItemIndex=o,this.showJustificationModal=!0):(t.unitPrice=t.tempPrice,t.editing=!1)},confirmPriceChange(){if(!this.justificationText.trim()){alert("Please provide a justification for the price change.");return}const o=this.poDetails.items[this.currentItemIndex];o.unitPrice=o.tempPrice,o.cost=o.tempPrice,o.justification=this.justificationText.trim(),o.editing=!1,this.closeJustificationModal()},closeJustificationModal(){this.showJustificationModal=!1,this.currentItemIndex=null,this.justificationText=""},handleSubmitRequisition(){if(this.form.items.length===0){alert("Please add at least one item to the requisition.");return}this.isSubmitting=!0;const o=this.collectFormData("under-review");this.$emit("submit-requisition",o),setTimeout(()=>{this.resetForm(),this.isSubmitting=!1},1e3)},handleSubmitInfoResponse(o){if(!this.infoResponse||this.infoResponse.trim()===""){alert("Please enter a response before submitting.");return}this.$emit("submit-info-response",{req:o,response:this.infoResponse}),this.infoResponse=""},handleApproveRequisition(o){this.$emit("approve-requisition",o)},handleDeclineRequisition(o){this.$emit("decline-requisition",o)},handleInfoRequisition(o){this.$emit("info-requisition",o)},handleCreatePO(o){this.$emit("create-po",o)},handleOpenPO(o){this.$emit("open-po",o)},handleFinishPO(o){this.$emit("finish-po",o)},handleAcceptDelivery(o){this.$emit("accept-delivery",o)},collectFormData(o){var t,r,l;return{id:"REQ-"+Date.now(),requestor:((t=this.userProfile)==null?void 0:t.full_name)||"Unknown",department:this.form.department,project:this.form.project,neededDate:this.form.neededDate,justification:this.form.justification,items:this.form.items.map(n=>({...n})),status:o,submittedDate:new Date().toLocaleDateString(),profile_id:((r=this.userProfile)==null?void 0:r.id)||((l=this.userProfile)==null?void 0:l.profile_id)}},resetForm(){this.form={requestor:"",department:"",project:"",neededDate:"",justification:"",items:[]},this.addItem()},updatePODetails(o){this.poDetails={...o},this.getNumber();for(let t of this.poDetails.items||[])t.tempPrice=t.cost||0,t.unitPrice=t.unitPrice||t.cost||0,t.subTotal=t.unitPrice*(t.qty||0)},updateVendorInfo(o){this.vendorInfo={...o}},setPrintingMode(o){this.isPrinting=o},getNumber(){return(this.poDetails.items||[]).map((o,t)=>o.itemNumber=t+1)}},created(){this.addItem()}},za={class:"s-container container"},Oa={class:"nav-tabs"},Ua=["onClick"],ja={key:0,class:"tab-content active"},Ga={class:"form-grid"},Ha={class:"form-group"},Wa=["value"],Qa={class:"form-group"},Ja=["value"],Ya={class:"form-group"},Za=["value"],Ka={class:"form-group"},$a=["min"],Xa={class:"form-group"},va={class:"items-section"},ed={class:"items-header"},td={class:"form-group"},od=["onUpdate:modelValue"],sd={class:"form-group"},nd=["onUpdate:modelValue"],id={class:"form-group"},ld=["onUpdate:modelValue"],rd={class:"form-group"},ad=["onUpdate:modelValue"],dd=["value"],cd={class:"form-group"},md=["onUpdate:modelValue"],pd=["onClick"],fd={class:"action-buttons"},hd=["disabled"],gd={key:1,class:"tab-content active"},yd={class:"requisition-list"},Ed={class:"requisition-header"},Nd={class:"requisition-id"},bd={class:"requisition-details"},Vd={class:"detail-label"},kd={class:"detail-value"},wd={key:0,class:"form-group comments-section"},Cd=["onClick"],Dd={key:2,class:"tab-content active"},_d={class:"requisition-list"},ud={class:"requisition-header"},Sd={class:"requisition-id"},Fd={class:"requisition-details"},Bd={class:"detail-label"},xd={class:"detail-value"},Td={key:0,class:"form-group comments-section"},Rd=["onClick"],Ad={key:3,class:"tab-content active"},Pd={class:"requisition-list",id:"approvalsQueue"},Md={class:"requisition-header"},Id={class:"requisition-id"},Ld={class:"requisition-details"},qd={class:"detail-label"},zd={class:"detail-value"},Od={class:"detail-item"},Ud={class:"detail-value"},jd={class:"detail-item"},Gd={class:"item-list"},Hd=["onClick"],Wd=["onClick"],Qd=["onClick"],Jd={key:4,class:"tab-content active"},Yd={class:"requisition-list",id:"purchasingQueue"},Zd={class:"requisition-header"},Kd={class:"requisition-id"},$d={class:"requisition-details"},Xd={class:"detail-label"},vd={class:"detail-value"},ec={class:"detail-item"},tc={class:"detail-value"},oc={class:"detail-item"},sc={class:"item-list"},nc=["onClick"],ic={key:5,class:"tab-content active"},lc={class:"requisition-list",id:"receivingQueue"},rc={class:"requisition-header"},ac={class:"requisition-id"},dc={class:"requisition-details"},cc={class:"detail-label"},mc={class:"detail-value"},pc={class:"detail-item"},fc={class:"detail-value"},hc={class:"detail-item"},gc={class:"item-list"},yc=["onClick"],Ec={key:6,class:"tab-content active"},Nc={class:"po-content",id:"po-content"},bc={class:"po-header"},Vc={class:"company-info"},kc={class:"info-row"},wc={class:"info-value"},Cc={class:"info-row"},Dc={class:"info-value"},_c={class:"info-row"},uc={class:"info-value"},Sc={class:"info-row"},Fc={class:"info-label"},Bc={class:"info-row"},xc={class:"info-value"},Tc={class:"company-info"},Rc={class:"info-row"},Ac={class:"info-value"},Pc={class:"info-row"},Mc={class:"info-value"},Ic={class:"info-row"},Lc={class:"info-value"},qc={class:"info-row"},zc={class:"info-value"},Oc={class:"info-row"},Uc={class:"info-value"},jc={class:"items-section"},Gc={class:"items-table"},Hc={key:0},Wc={key:0},Qc={key:0,class:"price-change-indicator"},Jc=["onUpdate:modelValue"],Yc={key:0},Zc=["onClick"],Kc={key:1},$c=["onClick"],Xc=["onClick"],vc={key:0,class:"justification-note"},em={class:"totals"},tm={class:"total-row"},om={class:"total-row"},sm={class:"total-row"},nm={class:"total-row grand-total"},im={class:"modal-content"},lm={style:{"margin-bottom":"15px",color:"#666"}},rm={class:"modal-buttons"},am=["disabled"],dm={key:7,class:"tab-content active"};function cm(o,t,r,l,n,i){var s,a,c,y,w,N,D,_,C,p,h,b,k;return e.openBlock(),e.createElementBlock("div",za,[t[60]||(t[60]=e.createElementVNode("div",{class:"header"},[e.createElementVNode("h1",null,"OceanHelm Requisition System"),e.createElementVNode("p",null,"Streamlined Material Request & Ordering Process")],-1)),e.createElementVNode("div",Oa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.visibleTabs,d=>(e.openBlock(),e.createElementBlock("button",{key:d.name,class:e.normalizeClass(["nav-tab",{active:n.activeTab===d.name}]),onClick:m=>i.setActiveTab(d.name)},e.toDisplayString(d.label),11,Ua))),128))]),n.activeTab==="new-requisition"?(e.openBlock(),e.createElementBlock("div",ja,[e.createElementVNode("form",{onSubmit:t[5]||(t[5]=e.withModifiers((...d)=>i.handleSubmitRequisition&&i.handleSubmitRequisition(...d),["prevent"]))},[e.createElementVNode("div",Ga,[e.createElementVNode("div",Ha,[t[12]||(t[12]=e.createElementVNode("label",null,"Requestor Name *",-1)),e.createElementVNode("input",{type:"text",value:(s=r.userProfile)==null?void 0:s.full_name,readonly:"",required:"",class:"form-control"},null,8,Wa)]),e.createElementVNode("div",Qa,[t[14]||(t[14]=e.createElementVNode("label",null,"Department *",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[0]||(t[0]=d=>n.form.department=d),required:""},[t[13]||(t[13]=e.createElementVNode("option",{value:""},"Select Department",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.departments,d=>(e.openBlock(),e.createElementBlock("option",{key:d,value:d},e.toDisplayString(d),9,Ja))),128))],512),[[e.vModelSelect,n.form.department]])]),e.createElementVNode("div",Ya,[t[16]||(t[16]=e.createElementVNode("label",null,"Vessel *",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":t[1]||(t[1]=d=>n.form.project=d),class:"form-control",required:""},[t[15]||(t[15]=e.createElementVNode("option",{disabled:"",value:""},"Select a vessel",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.vessels,d=>(e.openBlock(),e.createElementBlock("option",{key:d.id,value:d.name},e.toDisplayString(d.name),9,Za))),128))],512),[[e.vModelSelect,n.form.project]])]),e.createElementVNode("div",Ka,[t[17]||(t[17]=e.createElementVNode("label",null,"Date Needed *",-1)),e.withDirectives(e.createElementVNode("input",{type:"date","onUpdate:modelValue":t[2]||(t[2]=d=>n.form.neededDate=d),min:i.today,required:""},null,8,$a),[[e.vModelText,n.form.neededDate]])])]),e.createElementVNode("div",Xa,[t[18]||(t[18]=e.createElementVNode("label",null,"Business Justification *",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":t[3]||(t[3]=d=>n.form.justification=d),placeholder:"Explain why these materials are needed...",required:""},null,512),[[e.vModelText,n.form.justification]])]),e.createElementVNode("div",va,[e.createElementVNode("div",ed,[t[19]||(t[19]=e.createElementVNode("h3",null,"Requested Items",-1)),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:t[4]||(t[4]=(...d)=>i.addItem&&i.addItem(...d))},"+ Add Item")]),e.createElementVNode("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.form.items,(d,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:"item-row"},[e.createElementVNode("div",td,[t[20]||(t[20]=e.createElementVNode("label",null,"Item Code *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":g=>d.id=g,required:""},null,8,od),[[e.vModelText,d.id]])]),e.createElementVNode("div",sd,[t[21]||(t[21]=e.createElementVNode("label",null,"Item Description *",-1)),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":g=>d.desc=g,required:""},null,8,nd),[[e.vModelText,d.desc]])]),e.createElementVNode("div",id,[t[22]||(t[22]=e.createElementVNode("label",null,"Quantity *",-1)),e.withDirectives(e.createElementVNode("input",{type:"number","onUpdate:modelValue":g=>d.qty=g,min:"1",required:""},null,8,ld),[[e.vModelText,d.qty,void 0,{number:!0}]])]),e.createElementVNode("div",rd,[t[23]||(t[23]=e.createElementVNode("label",null,"Unit *",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g=>d.unit=g,required:""},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.units,g=>(e.openBlock(),e.createElementBlock("option",{key:g,value:g},e.toDisplayString(g),9,dd))),128))],8,ad),[[e.vModelSelect,d.unit]])]),e.createElementVNode("div",cd,[t[24]||(t[24]=e.createElementVNode("label",null,"Est. Unit Cost *",-1)),e.withDirectives(e.createElementVNode("input",{type:"number","onUpdate:modelValue":g=>d.cost=g,step:"0.01",min:"0",placeholder:"0.00",required:""},null,8,md),[[e.vModelText,d.cost,void 0,{number:!0}]])]),e.createElementVNode("button",{type:"button",class:"remove-item-btn",onClick:g=>i.removeItem(m)},"Remove",8,pd)]))),128))])]),e.createElementVNode("div",fd,[e.createElementVNode("button",{type:"submit",class:"btn btn-primary-req",disabled:n.isSubmitting},e.toDisplayString(n.isSubmitting?"Submitting...":"Submit Requisition"),9,hd)])],32)])):e.createCommentVNode("",!0),n.activeTab==="all-requisitions"?(e.openBlock(),e.createElementBlock("div",gd,[e.createElementVNode("div",yd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.requisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",Ed,[e.createElementVNode("div",Nd,e.toDisplayString(d.id),1),e.createElementVNode("div",{class:e.normalizeClass(["status-badge",`status-${d.status}`])},e.toDisplayString(d.status),3)]),e.createElementVNode("div",bd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.getRequisitionFields(d),m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",Vd,e.toDisplayString(m.label),1),e.createElementVNode("div",kd,e.toDisplayString(m.value(d)),1)]))),128))]),d.status==="po-created"||d.status==="delivered"?(e.openBlock(),e.createElementBlock("div",wd,[e.createElementVNode("button",{onClick:m=>i.handleOpenPO(d.id),class:"add-item-btn comments-section"}," Print PO ",8,Cd)])):e.createCommentVNode("",!0)]))),128))])])):e.createCommentVNode("",!0),n.activeTab==="my-requisitions"?(e.openBlock(),e.createElementBlock("div",Dd,[e.createElementVNode("div",_d,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.myRequisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",ud,[e.createElementVNode("div",Sd,e.toDisplayString(d.id),1),e.createElementVNode("div",{class:e.normalizeClass(["status-badge",`status-${d.status}`])},e.toDisplayString(d.status),3)]),e.createElementVNode("div",Fd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.getRequisitionFields(d),m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",Bd,e.toDisplayString(m.label),1),e.createElementVNode("div",xd,e.toDisplayString(m.value(d)),1)]))),128))]),d.status==="info-requested"?(e.openBlock(),e.createElementBlock("div",Td,[t[25]||(t[25]=e.createElementVNode("label",{class:"detail-label"},"Your Response",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":t[6]||(t[6]=m=>n.infoResponse=m),class:"response-textarea",placeholder:"Submit more info..."},null,512),[[e.vModelText,n.infoResponse]]),e.createElementVNode("button",{onClick:m=>i.handleSubmitInfoResponse(d),class:"add-item-btn comments-section"}," Submit Info ",8,Rd)])):e.createCommentVNode("",!0)]))),128))])])):e.createCommentVNode("",!0),n.activeTab==="approvals"?(e.openBlock(),e.createElementBlock("div",Ad,[t[28]||(t[28]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},[e.createElementVNode("h3",{style:{color:"#1e40af","margin-bottom":"15px"}},"Department Supervisor Dashboard"),e.createElementVNode("div",{style:{background:"#fef3c7",padding:"15px","border-radius":"10px","border-left":"4px solid #f59e0b"}},[e.createElementVNode("strong",null,"Role:"),e.createTextVNode(" Department Supervisor - Review requests for accuracy, necessity, and budget compliance ")])],-1)),e.createElementVNode("div",Pd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.reviewRequisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",Md,[e.createElementVNode("div",Id,e.toDisplayString(d.id),1)]),e.createElementVNode("div",Ld,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.requisitionFields,m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",qd,e.toDisplayString(m.label),1),e.createElementVNode("div",zd,e.toDisplayString(m.value(d)),1)]))),128))]),e.createElementVNode("div",Od,[t[26]||(t[26]=e.createElementVNode("div",{class:"detail-label"},"Justification",-1)),e.createElementVNode("div",Ud,e.toDisplayString(d.justification||"N/A"),1)]),e.createElementVNode("div",jd,[t[27]||(t[27]=e.createElementVNode("div",{class:"detail-label"},"Items",-1)),e.createElementVNode("ul",Gd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(m,g)=>(e.openBlock(),e.createElementBlock("li",{key:g},e.toDisplayString(m.desc)+" - "+e.toDisplayString(m.qty)+" "+e.toDisplayString(m.unit)+" @ ₦"+e.toDisplayString(m.cost.toFixed(2))+" each ",1))),128))])]),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:m=>i.handleApproveRequisition(d.id)},"Approve",8,Hd),e.createElementVNode("button",{type:"button",class:"marginbox btn-reject",onClick:m=>i.handleDeclineRequisition(d.id)},"Decline",8,Wd),e.createElementVNode("button",{type:"button",class:"marginbox btn-request",onClick:m=>i.handleInfoRequisition(d.id)},"Request Info",8,Qd)]))),128))])])):e.createCommentVNode("",!0),n.activeTab==="purchasing"?(e.openBlock(),e.createElementBlock("div",Jd,[t[31]||(t[31]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},[e.createElementVNode("h3",{style:{color:"#1e40af","margin-bottom":"15px"}},"Purchasing Department Dashboard"),e.createElementVNode("div",{style:{background:"#dbeafe",padding:"15px","border-radius":"10px","border-left":"4px solid #3b82f6"}},[e.createElementVNode("strong",null,"Role:"),e.createTextVNode(" Purchasing Team - Convert approved requisitions to Purchase Orders ")])],-1)),e.createElementVNode("div",Yd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.poRequisitions,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",Zd,[e.createElementVNode("div",Kd,e.toDisplayString(d.id),1)]),e.createElementVNode("div",$d,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.requisitionFields,m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",Xd,e.toDisplayString(m.label),1),e.createElementVNode("div",vd,e.toDisplayString(m.value(d)),1)]))),128))]),e.createElementVNode("div",ec,[t[29]||(t[29]=e.createElementVNode("div",{class:"detail-label"},"Justification",-1)),e.createElementVNode("div",tc,e.toDisplayString(d.justification||"N/A"),1)]),e.createElementVNode("div",oc,[t[30]||(t[30]=e.createElementVNode("div",{class:"detail-label"},"Items",-1)),e.createElementVNode("ul",sc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(m,g)=>(e.openBlock(),e.createElementBlock("li",{key:g},e.toDisplayString(m.desc)+" - "+e.toDisplayString(m.qty)+" "+e.toDisplayString(m.unit)+" @ ₦"+e.toDisplayString(m.cost.toFixed(2))+" each ",1))),128))])]),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:m=>i.handleCreatePO(d.id)},"Create PO",8,nc)]))),128))])])):e.createCommentVNode("",!0),n.activeTab==="receiving"?(e.openBlock(),e.createElementBlock("div",ic,[t[34]||(t[34]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},[e.createElementVNode("h3",{style:{color:"#1e40af","margin-bottom":"15px"}},"Receiving & Inventory Dashboard"),e.createElementVNode("div",{style:{background:"#dcfce7",padding:"15px","border-radius":"10px","border-left":"4px solid #10b981"}},[e.createElementVNode("strong",null,"Role:"),e.createTextVNode(" Warehouse Team - Process incoming deliveries and update inventory ")])],-1)),e.createElementVNode("div",lc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.awaitingDelivery,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:"requisition-card"},[e.createElementVNode("div",rc,[e.createElementVNode("div",ac,e.toDisplayString(d.id),1)]),e.createElementVNode("div",dc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.requisitionFields,m=>(e.openBlock(),e.createElementBlock("div",{class:"detail-item",key:m.label},[e.createElementVNode("div",cc,e.toDisplayString(m.label),1),e.createElementVNode("div",mc,e.toDisplayString(m.value(d)),1)]))),128))]),e.createElementVNode("div",pc,[t[32]||(t[32]=e.createElementVNode("div",{class:"detail-label"},"Justification",-1)),e.createElementVNode("div",fc,e.toDisplayString(d.justification||"N/A"),1)]),e.createElementVNode("div",hc,[t[33]||(t[33]=e.createElementVNode("div",{class:"detail-label"},"Items",-1)),e.createElementVNode("ul",gc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(m,g)=>(e.openBlock(),e.createElementBlock("li",{key:g},e.toDisplayString(m.desc)+" - "+e.toDisplayString(m.qty)+" "+e.toDisplayString(m.unit)+" @ ₦"+e.toDisplayString(m.cost.toFixed(2))+" each ",1))),128))])]),e.createElementVNode("button",{type:"button",class:"add-item-btn",onClick:m=>i.handleAcceptDelivery(d.id)},"Accept Delivery",8,yc)]))),128))])])):e.createCommentVNode("",!0),n.activeTab==="po"?(e.openBlock(),e.createElementBlock("div",Ec,[e.createElementVNode("div",Nc,[e.createElementVNode("div",bc,[e.createElementVNode("div",Vc,[t[40]||(t[40]=e.createElementVNode("h3",null,"Vendor Information",-1)),e.createElementVNode("div",kc,[t[35]||(t[35]=e.createElementVNode("span",{class:"info-label"},"Company:",-1)),e.createElementVNode("span",wc,e.toDisplayString(n.vendorInfo.company||((a=n.poDetails.vendorInfo)==null?void 0:a.company)||"N/A"),1)]),e.createElementVNode("div",Cc,[t[36]||(t[36]=e.createElementVNode("span",{class:"info-label"},"Contact:",-1)),e.createElementVNode("span",Dc,e.toDisplayString(n.vendorInfo.contact||((c=n.poDetails.vendorInfo)==null?void 0:c.contact)||"N/A"),1)]),e.createElementVNode("div",_c,[t[37]||(t[37]=e.createElementVNode("span",{class:"info-label"},"Email:",-1)),e.createElementVNode("span",uc,e.toDisplayString(n.vendorInfo.email||((y=n.poDetails.vendorInfo)==null?void 0:y.email)||"N/A"),1)]),e.createElementVNode("div",Sc,[t[38]||(t[38]=e.createElementVNode("span",{class:"info-label"},"Phone:",-1)),e.createElementVNode("span",Fc,e.toDisplayString(n.vendorInfo.phone||((w=n.poDetails.vendorInfo)==null?void 0:w.phone)||"N/A"),1)]),e.createElementVNode("div",Bc,[t[39]||(t[39]=e.createElementVNode("span",{class:"info-label"},"Address:",-1)),e.createElementVNode("span",xc,e.toDisplayString(n.vendorInfo.address||((N=n.poDetails.vendorInfo)==null?void 0:N.address)||"N/A"),1)])]),e.createElementVNode("div",Tc,[t[46]||(t[46]=e.createElementVNode("h3",null,"Purchase Order Details",-1)),e.createElementVNode("div",Rc,[t[41]||(t[41]=e.createElementVNode("span",{class:"info-label"},"PO Number:",-1)),e.createElementVNode("span",Ac,e.toDisplayString(n.poDetails.id),1)]),e.createElementVNode("div",Pc,[t[42]||(t[42]=e.createElementVNode("span",{class:"info-label"},"Date:",-1)),e.createElementVNode("span",Mc,e.toDisplayString(n.vendorInfo.poDate||((D=n.poDetails.vendorInfo)==null?void 0:D.poDate)||i.formatDate(new Date)),1)]),e.createElementVNode("div",Ic,[t[43]||(t[43]=e.createElementVNode("span",{class:"info-label"},"Requested By:",-1)),e.createElementVNode("span",Lc,e.toDisplayString(n.vendorInfo.poApproved||((_=n.poDetails.vendorInfo)==null?void 0:_.poApproved)||"N/A"),1)]),e.createElementVNode("div",qc,[t[44]||(t[44]=e.createElementVNode("span",{class:"info-label"},"Department:",-1)),e.createElementVNode("span",zc,"PO-"+e.toDisplayString(n.poDetails.department||"N/A"),1)]),e.createElementVNode("div",Oc,[t[45]||(t[45]=e.createElementVNode("span",{class:"info-label"},"Delivery Date:",-1)),e.createElementVNode("span",Uc,e.toDisplayString(n.poDetails.neededDate||"N/A"),1)])])]),e.createElementVNode("div",jc,[t[55]||(t[55]=e.createElementVNode("h2",{class:"section-title"},"Order Items",-1)),e.createElementVNode("table",Gc,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[t[47]||(t[47]=e.createElementVNode("th",null,"Item #",-1)),t[48]||(t[48]=e.createElementVNode("th",null,"Description",-1)),t[49]||(t[49]=e.createElementVNode("th",null,"Quantity",-1)),t[50]||(t[50]=e.createElementVNode("th",null,"Unit Price",-1)),t[51]||(t[51]=e.createElementVNode("th",null,"Total",-1)),n.isPrinting?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("th",Hc,"Actions"))])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.poDetails.items||[],(d,m)=>(e.openBlock(),e.createElementBlock("tr",{key:m},[e.createElementVNode("td",null,e.toDisplayString(d.itemNumber||m+1),1),e.createElementVNode("td",null,e.toDisplayString(d.desc),1),e.createElementVNode("td",null,e.toDisplayString(d.qty),1),e.createElementVNode("td",null,[d.editing?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":g=>d.tempPrice=g,type:"number",step:"0.01",min:"0",class:e.normalizeClass(["price-input",{"price-changed":d.cost!==d.tempPrice}])},null,10,Jc)),[[e.vModelText,d.tempPrice,void 0,{number:!0}]]):(e.openBlock(),e.createElementBlock("span",Wc,[e.createTextVNode(" $"+e.toDisplayString((d.unitPrice||d.cost||0).toFixed(2))+" ",1),d.cost!==d.unitPrice&&d.unitPrice?(e.openBlock(),e.createElementBlock("span",Qc,"!")):e.createCommentVNode("",!0)]))]),e.createElementVNode("td",null,"$"+e.toDisplayString(((d.unitPrice||d.cost||0)*(d.qty||0)).toFixed(2)),1),n.isPrinting?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("td",Yc,[d.editing?(e.openBlock(),e.createElementBlock("div",Kc,[e.createElementVNode("button",{onClick:g=>i.savePrice(m),class:"save-btn"},"Save",8,$c),e.createElementVNode("button",{onClick:g=>i.cancelEdit(m),class:"cancel-btn"},"Cancel",8,Xc)])):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:g=>i.startEdit(m),class:"edit-btn"}," Edit Price ",8,Zc))]))]))),128))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.poDetails.items||[],(d,m)=>(e.openBlock(),e.createElementBlock("div",{key:"note-"+m},[d.justification?(e.openBlock(),e.createElementBlock("div",vc,[e.createElementVNode("strong",null,"Price Change Justification (Item "+e.toDisplayString(d.itemNumber||m+1)+"):",1),e.createTextVNode(" "+e.toDisplayString(d.justification),1)])):e.createCommentVNode("",!0)]))),128)),e.createElementVNode("div",em,[e.createElementVNode("div",tm,[t[52]||(t[52]=e.createElementVNode("span",null,"Subtotal:",-1)),e.createElementVNode("span",null,"$"+e.toDisplayString(i.subTotal.toFixed(2)),1)]),e.createElementVNode("div",om,[e.createElementVNode("span",null,"Tax ("+e.toDisplayString(n.vendorInfo.tax||((C=n.poDetails.vendorInfo)==null?void 0:C.tax)||0)+"%):",1),e.createElementVNode("span",null,"$"+e.toDisplayString(i.calculateTax().toFixed(2)),1)]),e.createElementVNode("div",sm,[t[53]||(t[53]=e.createElementVNode("span",null,"Shipping:",-1)),e.createElementVNode("span",null,"$"+e.toDisplayString(i.getOptional(n.vendorInfo.shipping)),1)]),e.createElementVNode("div",nm,[t[54]||(t[54]=e.createElementVNode("span",null,"Grand Total:",-1)),e.createElementVNode("span",null,"$"+e.toDisplayString(i.grandTotal.toFixed(2)),1)])])])]),n.showJustificationModal?(e.openBlock(),e.createElementBlock("div",{key:0,class:"justification-modal",onClick:t[10]||(t[10]=e.withModifiers((...d)=>i.closeJustificationModal&&i.closeJustificationModal(...d),["self"]))},[e.createElementVNode("div",im,[t[58]||(t[58]=e.createElementVNode("h3",null,"Price Change Justification Required",-1)),e.createElementVNode("p",lm,[t[56]||(t[56]=e.createTextVNode(" Please provide a justification for changing the price from ",-1)),e.createElementVNode("strong",null,"$"+e.toDisplayString((h=(p=i.currentItem)==null?void 0:p.cost)==null?void 0:h.toFixed(2)),1),t[57]||(t[57]=e.createTextVNode(" to ",-1)),e.createElementVNode("strong",null,"$"+e.toDisplayString((k=(b=i.currentItem)==null?void 0:b.tempPrice)==null?void 0:k.toFixed(2)),1)]),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":t[7]||(t[7]=d=>n.justificationText=d),class:"justification-textarea",placeholder:"Enter justification for price change...",required:""},null,512),[[e.vModelText,n.justificationText]]),e.createElementVNode("div",rm,[e.createElementVNode("button",{onClick:t[8]||(t[8]=(...d)=>i.closeJustificationModal&&i.closeJustificationModal(...d)),class:"cancel-btn"},"Cancel"),e.createElementVNode("button",{onClick:t[9]||(t[9]=(...d)=>i.confirmPriceChange&&i.confirmPriceChange(...d)),class:"save-btn",disabled:!n.justificationText.trim()}," Confirm Change ",8,am)])])])):e.createCommentVNode("",!0),n.isPrinting?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"add-item-btn",onClick:t[11]||(t[11]=d=>i.handleFinishPO(n.poDetails.id))},"Approve PO"))])):e.createCommentVNode("",!0),n.activeTab==="workflow"?(e.openBlock(),e.createElementBlock("div",dm,t[59]||(t[59]=[e.createStaticVNode('<div class="workflow-steps"><div class="workflow-step"><div class="step-icon completed">1</div><div class="step-title">Request Submitted</div></div><div class="workflow-step"><div class="step-icon active">2</div><div class="step-title">Department Review</div></div><div class="workflow-step"><div class="step-icon">3</div><div class="step-title">Management Approval</div></div><div class="workflow-step"><div class="step-icon">4</div><div class="step-title">Purchase Order Created</div></div><div class="workflow-step"><div class="step-icon">5</div><div class="step-title">Order Fulfilled</div></div></div><div style="background:white;padding:30px;border-radius:15px;margin-top:20px;"><h3 style="color:#1e40af;margin-bottom:20px;">Requisition Workflow Process</h3><div style="line-height:1.8;color:#374151;"><p><strong>Step 1: Request Identification</strong><br> Department or individual identifies need for materials, equipment, or services.</p><p><strong>Step 2: Requisition Creation</strong><br> Complete requisition form with detailed specifications, quantities, and business justification.</p><p><strong>Step 3: Department Review</strong><br> Department supervisor reviews request for accuracy, necessity, and budget compliance.</p><p><strong>Step 4: Management Approval</strong><br> Based on cost thresholds, appropriate management level provides approval.</p><p><strong>Step 5: Purchase Order Generation</strong><br> Purchasing team converts approved requisition into formal Purchase Order (PO).</p><p><strong>Step 6: Vendor Processing</strong><br> PO sent to vendor, order processed, and delivery scheduled.</p><p><strong>Step 7: Receipt &amp; Inventory</strong><br> Goods received, inspected, and entered into inventory system.</p></div></div>',2)]))):e.createCommentVNode("",!0)])}const z=S(qa,[["render",cm]]),mm=(o={})=>({brandName:o.brandName||"OceanHelm",logoIcon:o.logoIcon||"bi bi-water",showLogo:o.showLogo!==!1,responsive:o.responsive!==!1,...o}),pm=[{type:"link",label:"Home",icon:"bi bi-house",roles:["owner","super-staff","staff","captain"],href:"/app/dashboard",active:!0},{type:"button",label:"Guide",icon:"bi bi-compass",action:"guide",roles:["crew"]},{type:"link",label:"Activity Log",icon:"bi bi-activity",href:"/activity-log",roles:["owner"]},{type:"link",label:"People Manager",icon:"bi bi-person-plus",href:"/app/people-manager",roles:["owner","super-staff"]},{type:"text",label:"Modules"},{type:"dropdown",label:"Compliance",roles:["owner","super-staff","staff","captain"],icon:"bi bi-list-ul",children:[{label:"Vessel Certification",action:"vessel-cert"},{label:"Reports",action:"reports"},{label:"Crew Certification",action:"crew-cert"},{label:"QHSE Compliance",action:"qhse"},{label:"Track Garbage",action:"garbage"}]},{type:"dropdown",label:"HR",icon:"bi bi-people-fill",roles:["owner","super-staff","staff"],categories:["hr"],children:[{label:"Attendance",action:"hr-attendance",roles:["owner","super-staff","staff"],categories:["hr"]},{label:"Payroll",action:"hr-payroll",roles:["owner","super-staff","staff"],categories:["hr"]},{label:"Appraisals",action:"hr-appraisals",roles:["owner","super-staff","staff"],categories:["hr"]},{label:"Leave Management",action:"hr-leave",roles:["owner","super-staff","staff"],categories:["hr"]},{label:"Disciplinary Log",action:"hr-disciplinary",roles:["owner"]}]},{type:"dropdown",label:"Recruitment",icon:"bi bi-person-fill-add",roles:["owner","super-staff","staff"],categories:["hr"],children:[{label:"Manage Recruitment",action:"recruitment-builder",roles:["owner","super-staff","staff"],categories:["hr"]}]},{type:"button",label:"Maintenance",icon:"bi bi-tools",action:"maintenance",roles:["owner","super-staff","staff","captain"]},{type:"dropdown",label:"Crew Management",icon:"bi bi-people",roles:["owner","super-staff","staff","captain"],children:[{label:"All Crew",action:"crew-all",roles:["owner","super-staff","staff"]},{label:"Get Crew by Vessel",action:"crew-by-vessel"},{label:"Schedule",action:"schedule"}]},{type:"dropdown",label:"Inventory Management",icon:"bi bi-clipboard-data",roles:["owner","super-staff","staff","captain"],children:[{label:"Parts Inventory",action:"inventory",roles:["owner","super-staff","staff","captain"]},{label:"Bunkering",action:"fuel",roles:["owner","super-staff","staff","captain"]}]},{type:"link",label:"Requisition Processing",icon:"bi bi-calendar-check",href:"/app/requisition",roles:["owner","super-staff","staff","captain"]},{type:"button",label:"Voyage Manager",icon:"fas fa-ship",action:"coming-soon",roles:["owner","super-staff","staff","captain"]},{type:"button",label:"Vessel Log",icon:"bi bi-file-ruled",action:"coming-soon",roles:["owner","super-staff","staff","captain"]},{type:"button",label:"Profile",icon:"bi bi-people",action:"crew-profile",roles:["crew"]},{type:"button",label:"Training",icon:"bi bi-book",action:"crew-training",roles:["crew"]},{type:"button",label:"Settings",icon:"bi bi-gear",action:"settings",roles:["owner","super-staff","staff"]},{type:"button",label:"Help & Support",icon:"bi bi-question-circle",action:"help"}],fm=(o,t)=>!o.roles||o.roles.length===0?!0:o.roles.includes(t==null?void 0:t.role),hm={install(o,t={}){o.component("ConfigurableSidebar",R),o.component("VesselLists",A),o.component("DashHead",P),o.component("Reports",M),o.component("ActivityLogs",L),o.component("CrewManagement",q),o.component("RequisitionSystem",z),o.component("OceanHelmMaintenance",I),o.provide("sidebarConfig",t)}};V.ActivityLogs=L,V.ConfigurableSidebar=R,V.CrewManagement=q,V.DashHead=P,V.OceanHelmMaintenance=I,V.Reports=M,V.RequisitionSystem=z,V.VesselList=A,V.createSidebarConfig=mm,V.default=hm,V.defaultMenuItems=pm,V.defaultPermissionChecker=fm,Object.defineProperties(V,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
10
  //# sourceMappingURL=oceanhelm.umd.js.map