62 lines
106 KiB
JavaScript
62 lines
106 KiB
JavaScript
import{r as D,c as X,o as Ee,aO as Ln,_ as rt,m as tt,a as R,g as k,b as r,j as W,t as $,d as x,w as B,k as q,e as C,F as J,ac as Fn,h as De,s as Bn,v as Vn,ad as Un,i as Ae,n as ne,Q as _t,af as Qe,aR as We,ae as zn,aV as Hn}from"./index-QAlcqU00.js";import{u as $n,A as me,C as jn,a as Yn,b as Gn,S as qn}from"./assets-CvfPiugk.js";import{u as Qn}from"./locations-ElrWcwNd.js";import{u as Wn,W as Jn,C as Kn}from"./CustomFieldsForm-BwcGiCuE.js";import{u as Xn}from"./useMobileOptimization-Ds6Eb1bE.js";import{F as Zn,a as ea}from"./FPPageHeader-CFIwZZgQ.js";import{F as oe}from"./FPInput-D5RURom0.js";import{F as ce}from"./FPSelect-j7n_x8eB.js";import{F as ta}from"./FPStats-DOY0PQQF.js";import{F as na}from"./FPTable-CWvngIYd.js";import{F as Rt}from"./FPModal-DMoPysvU.js";import{F as ge}from"./FPBadge-DvOitM1C.js";import{F as Dt}from"./FPTabs-qq-Tmb7J.js";import{F as Pt}from"./FPFileUpload-Bk17EQTg.js";import{_ as aa}from"./FormRestoreNotification-2Wflg1mH.js";import"./FPCheckbox-DcRYwN3n.js";import"./FPCard-AB6NRXg5.js";function oa(){const e=D({}),t=D([]),i=D([]),s=D([]),n=D([]),o=D([]),u=D(!1),c=D(null),d=X(()=>{if(!e.value.healthMetrics)return 0;const v=e.value.healthMetrics,l={availability:.3,reliability:.25,performance:.2,quality:.15,safety:.1};let m=0;return Object.entries(l).forEach(([g,O])=>{m+=(v[g]||0)*O}),Math.round(m)}),y=X(()=>t.value.filter(v=>v.healthScore<60||v.downtime>20)),A=X(()=>t.value.filter(v=>v.healthScore>=90).sort((v,l)=>l.healthScore-v.healthScore).slice(0,10)),H=X(()=>{if(!n.value.length)return{};const v=n.value[n.value.length-1],l=n.value[n.value.length-2];if(!l)return{trend:"stable",change:0};const m=(v.total-l.total)/l.total*100;return{trend:m>5?"increasing":m<-5?"decreasing":"stable",change:Math.round(m*100)/100,current:v.total,previous:l.total}}),b=[{id:"availability",name:"Asset Availability",description:"Percentage of time asset is operational",unit:"%",target:95,formula:"(Uptime / Total Time) × 100"},{id:"reliability",name:"Asset Reliability",description:"Mean time between failures",unit:"hours",target:1e3,formula:"Operating Time / Number of Failures"},{id:"performance",name:"Performance Efficiency",description:"Actual vs designed performance",unit:"%",target:90,formula:"(Actual Output / Designed Output) × 100"},{id:"oee",name:"Overall Equipment Effectiveness",description:"Combined availability, performance, and quality",unit:"%",target:85,formula:"Availability × Performance × Quality"},{id:"mtbf",name:"Mean Time Between Failures",description:"Average time between breakdowns",unit:"hours",target:2e3,formula:"Total Operating Time / Number of Failures"},{id:"mttr",name:"Mean Time To Repair",description:"Average time to restore after failure",unit:"hours",target:4,formula:"Total Repair Time / Number of Repairs"}],P=[{id:"asset_performance",name:"Asset Performance Report",description:"Comprehensive performance analysis",frequency:["DAILY","WEEKLY","MONTHLY","QUARTERLY"],metrics:["availability","reliability","performance","oee"]},{id:"maintenance_summary",name:"Maintenance Summary",description:"Maintenance activities and costs",frequency:["WEEKLY","MONTHLY","QUARTERLY"],metrics:["maintenance_cost","work_orders","compliance"]},{id:"cost_analysis",name:"Cost Analysis Report",description:"Financial analysis of asset operations",frequency:["MONTHLY","QUARTERLY","ANNUAL"],metrics:["total_cost","maintenance_cost","parts_cost","labor_cost"]},{id:"compliance_audit",name:"Compliance Audit",description:"Regulatory compliance status",frequency:["MONTHLY","QUARTERLY","ANNUAL"],metrics:["inspections","certifications","violations"]},{id:"lifecycle_analysis",name:"Asset Lifecycle Analysis",description:"Asset age, depreciation, and replacement planning",frequency:["QUARTERLY","ANNUAL"],metrics:["age","depreciation","replacement_cost","eol_prediction"]}],V=async(v,l="30d")=>{try{u.value=!0,c.value=null;const[m,g,O,U,j]=await Promise.all([analyticsRepository.getAssetAnalytics(v,l),analyticsRepository.getPerformanceMetrics(v,l),analyticsRepository.getTrendData(v,l),analyticsRepository.getComplianceData(v,l),analyticsRepository.getCostAnalysis(v,l)]);e.value=m.data||m,t.value=g.data||g,i.value=O.data||O,s.value=U.data||U,n.value=j.data||j}catch(m){c.value=m.message||"Failed to load asset analytics",console.error("Error loading asset analytics:",m)}finally{u.value=!1}},z=async(v,l,m,g={})=>{try{u.value=!0;const O={templateId:v,assetIds:Array.isArray(l)?l:[l],startDate:m.start,endDate:m.end,parameters:g,format:"JSON",generatedAt:new Date().toISOString()},U=await reportRepository.generate(O),j=U.data||U;return o.value.push(j),j}catch(O){throw c.value=O.message||"Failed to generate report",O}finally{u.value=!1}},Y=(v,l)=>{var j,K;const m=b.find(re=>re.id===v);if(!m||!l)return null;let g=0;switch(v){case"availability":g=l.uptime&&l.totalTime?l.uptime/l.totalTime*100:0;break;case"reliability":g=l.operatingTime&&l.failures?l.operatingTime/l.failures:0;break;case"performance":g=l.actualOutput&&l.designedOutput?l.actualOutput/l.designedOutput*100:0;break;case"oee":const re=((j=Y("availability",l))==null?void 0:j.value)||0,L=((K=Y("performance",l))==null?void 0:K.value)||0,h=l.qualityRate||100;g=re/100*(L/100)*(h/100)*100;break;case"mtbf":g=l.operatingTime&&l.failures?l.operatingTime/l.failures:0;break;case"mttr":g=l.repairTime&&l.repairs?l.repairTime/l.repairs:0;break;default:g=l[v]||0}const O=m.target,U=(g-O)/O*100;return{value:Math.round(g*100)/100,target:O,variance:Math.round(U*100)/100,status:Math.abs(U)<=5?"on_target":U>0?"above_target":"below_target",trend:N(v,l)}},N=(v,l)=>{if(!l.historical||l.historical.length<2)return"stable";const g=l.historical.slice(-3).map(j=>j[v]||0),O=g[g.length-1]-g[0],U=g[0]*.05;return Math.abs(O)<=U?"stable":O>0?"improving":"declining"},w=v=>{const l=[];return v.availability<90&&l.push({type:"warning",category:"availability",message:"Asset availability is below target",recommendation:"Review maintenance schedule and identify recurring issues",priority:"high"}),v.mtbf<500&&l.push({type:"alert",category:"reliability",message:"Mean time between failures is critically low",recommendation:"Investigate root causes and consider preventive maintenance",priority:"critical"}),v.maintenanceCost>v.replacementThreshold*.7&&l.push({type:"info",category:"cost",message:"Maintenance costs approaching replacement threshold",recommendation:"Evaluate asset lifecycle and replacement options",priority:"medium"}),v.performance<80&&l.push({type:"warning",category:"performance",message:"Asset performance is declining",recommendation:"Schedule performance assessment and calibration",priority:"high"}),l.sort((m,g)=>{const O={critical:4,high:3,medium:2,low:1};return O[g.priority]-O[m.priority]})},T=v=>{const l={age:v.age||0,utilization:v.utilizationRate||0,maintenanceCompliance:v.maintenanceCompliance||100,performance:v.performance||100,failures:v.recentFailures||0},m={age:.2,utilization:.2,maintenanceCompliance:.3,performance:.2,failures:.1};let g=0;g+=Math.min(l.age/20,1)*m.age*100;const O=l.utilization>90||l.utilization<10?1:0;g+=O*m.utilization*100,g+=(100-l.maintenanceCompliance)*m.maintenanceCompliance,g+=(100-l.performance)*m.performance,g+=Math.min(l.failures*10,100)*m.failures;const U=Math.min(g,100);return{riskScore:Math.round(U),riskLevel:U>=80?"high":U>=60?"medium":"low",timeToFailure:U>=80?"1-3 months":U>=60?"3-6 months":"6+ months",confidence:_(l),factors:Object.entries(l).map(([j,K])=>({name:j,value:K,impact:m[j]*100}))}},_=v=>{const l=Object.values(v).filter(m=>m!=null).length/Object.keys(v).length;return Math.round(l*100)},F=(v,l)=>{if(!v.length)return[];const g=[...v.map(U=>U[l]||0)].sort((U,j)=>j-U),O={p90:g[Math.floor(g.length*.1)],p75:g[Math.floor(g.length*.25)],p50:g[Math.floor(g.length*.5)],p25:g[Math.floor(g.length*.75)],p10:g[Math.floor(g.length*.9)]};return v.map(U=>{const j=U[l]||0;let K="bottom";return j>=O.p90?K="top":j>=O.p75?K="high":j>=O.p50?K="medium":j>=O.p25&&(K="low"),{...U,benchmark:{value:j,ranking:K,percentile:M(j,g)}}})},M=(v,l)=>{const m=l.findIndex(g=>g<=v);return m===-1?100:Math.round(m/l.length*100)},S=(v,l="csv")=>{switch(l.toLowerCase()){case"csv":return E(v);case"json":return JSON.stringify(v,null,2);case"excel":return G(v);default:return JSON.stringify(v,null,2)}},E=v=>{if(!Array.isArray(v)||v.length===0)return"";const l=Object.keys(v[0]);return[l.join(","),...v.map(g=>l.map(O=>`"${g[O]||""}"`).join(","))].join(`
|
||
`)},G=v=>E(v);return{analyticsData:e,performanceMetrics:t,trendData:i,complianceData:s,costAnalysis:n,reports:o,loading:u,error:c,assetHealthScore:d,criticalAssets:y,topPerformers:A,costTrends:H,kpiDefinitions:b,reportTemplates:P,loadAssetAnalytics:V,generateReport:z,calculateKPI:Y,calculateTrend:N,getAssetHealthInsights:w,predictAssetFailure:T,calculatePredictionConfidence:_,benchmarkAssets:F,calculatePercentile:M,exportReportData:S,exportToCSV:E,exportToExcel:G}}function sa(){const e=D(!1),t=D({}),i=D([]),s=D([]),n=D([]),o=D([]),u=D(null),c={FAILURE_PREDICTION:"failure_prediction",MAINTENANCE_OPTIMIZATION:"maintenance_optimization",COST_FORECASTING:"cost_forecasting",PERFORMANCE_ANALYSIS:"performance_analysis",ANOMALY_DETECTION:"anomaly_detection"},d=X(()=>i.value.length>0),y=X(()=>s.value.filter(M=>M.severity==="CRITICAL")),A=X(()=>n.value.filter(M=>M.priority==="HIGH")),H=async(M,S=30)=>{try{e.value=!0,await new Promise(v=>setTimeout(v,2e3));const E={assetId:M,failureProbability:Math.random()*.3+.1,predictedFailureDate:new Date(Date.now()+Math.random()*30*24*60*60*1e3),confidence:Math.random()*.3+.7,riskFactors:[{factor:"Operating hours exceeding recommended limits",weight:.3},{factor:"Temperature anomalies detected",weight:.25},{factor:"Vibration patterns indicate wear",weight:.2},{factor:"Maintenance intervals exceeded",weight:.15},{factor:"Historical failure patterns",weight:.1}],recommendedActions:["Schedule immediate inspection","Replace critical components","Increase monitoring frequency"],timeframe:S,generatedAt:new Date},G=i.value.findIndex(v=>v.assetId===M);return G>=0?i.value[G]=E:i.value.push(E),E}catch(E){throw console.error("Failed to predict asset failure:",E),u.value="Failed to generate failure prediction",E}finally{e.value=!1}},b=async M=>{try{e.value=!0,await new Promise(E=>setTimeout(E,1500));const S=M.map(E=>({assetId:E.id,currentInterval:E.maintenanceInterval||90,optimizedInterval:Math.floor(Math.random()*30)+75,potentialSavings:Math.floor(Math.random()*5e3)+1e3,riskReduction:Math.random()*.2+.1,reasoning:["Historical performance data analysis","Similar asset benchmarking","Operating condition factors","Cost-benefit optimization"],implementationDate:new Date(Date.now()+7*24*60*60*1e3)}));return n.value.push({id:`maintenance_opt_${Date.now()}`,type:"MAINTENANCE_OPTIMIZATION",title:"Optimized Maintenance Schedules",description:"AI-recommended maintenance schedule adjustments",optimizations:S,totalSavings:S.reduce((E,G)=>E+G.potentialSavings,0),priority:"MEDIUM",confidence:.85,generatedAt:new Date}),S}catch(S){throw console.error("Failed to optimize maintenance schedule:",S),u.value="Failed to optimize maintenance schedule",S}finally{e.value=!1}},P=async M=>{try{e.value=!0,await new Promise(E=>setTimeout(E,1e3));const S=[{id:`anomaly_${Date.now()}_1`,assetId:M.id,type:"PERFORMANCE",severity:"HIGH",metric:"Operating Temperature",normalRange:"18-22°C",currentValue:"26°C",deviation:.18,detectedAt:new Date,description:"Operating temperature significantly above normal range",potentialCauses:["Cooling system malfunction","Blocked air filters","Refrigerant leak"],recommendedActions:["Inspect cooling system immediately","Check and replace air filters","Schedule refrigerant level check"]},{id:`anomaly_${Date.now()}_2`,assetId:M.id,type:"VIBRATION",severity:"MEDIUM",metric:"Vibration Level",normalRange:"0.1-0.3 mm/s",currentValue:"0.45 mm/s",deviation:.12,detectedAt:new Date,description:"Vibration levels elevated above normal operating range",potentialCauses:["Bearing wear","Misalignment","Imbalanced components"],recommendedActions:["Schedule vibration analysis","Inspect bearings and alignment","Plan preventive maintenance"]}];return s.value.push(...S),S}catch(S){throw console.error("Failed to detect anomalies:",S),u.value="Failed to detect anomalies",S}finally{e.value=!1}},V=async(M,S=365)=>{try{e.value=!0,await new Promise(v=>setTimeout(v,1500));const E=Math.random()*1e4+5e3;return{assetId:M,timeframe:S,totalForecast:E,breakdown:{maintenance:E*.6,repairs:E*.25,replacements:E*.1,energy:E*.05},monthlyTrend:Array.from({length:12},(v,l)=>({month:l+1,projected:E/12*(1+Math.random()*.2-.1),confidence:Math.random()*.2+.8})),riskFactors:[{factor:"Asset age",impact:.15},{factor:"Operating conditions",impact:.1},{factor:"Historical patterns",impact:.2},{factor:"Market trends",impact:.05}],generatedAt:new Date}}catch(E){throw console.error("Failed to forecast costs:",E),u.value="Failed to forecast costs",E}finally{e.value=!1}},z=async(M,S=[])=>{try{e.value=!0,await new Promise(v=>setTimeout(v,1200));const E={assetId:M,overallScore:Math.random()*30+70,metrics:{efficiency:Math.random()*20+80,reliability:Math.random()*25+75,availability:Math.random()*15+85,performance:Math.random()*20+80},trends:{last30Days:Math.random()*10-5,last90Days:Math.random()*15-7.5,last365Days:Math.random()*20-10},benchmarking:{industryAverage:Math.random()*20+75,peerAssets:Math.random()*25+70,bestInClass:Math.random()*15+85},insights:["Performance consistently above industry average","Slight degradation in efficiency over last quarter","Reliability metrics excellent compared to similar assets","Opportunity for improvement in energy efficiency"],recommendations:["Continue current maintenance strategy","Investigate efficiency degradation causes","Consider energy optimization upgrades","Monitor performance trends closely"],generatedAt:new Date},G=o.value.findIndex(v=>v.assetId===M);return G>=0?o.value[G]=E:o.value.push(E),E}catch(E){throw console.error("Failed to analyze performance:",E),u.value="Failed to analyze performance",E}finally{e.value=!1}},Y=async M=>{try{e.value=!0,await new Promise(E=>setTimeout(E,1e3));const S=[{id:`rec_${Date.now()}_1`,type:"ENERGY_OPTIMIZATION",title:"Energy Efficiency Improvement",description:"Upgrade HVAC controls to reduce energy consumption by 15%",priority:"HIGH",estimatedSavings:12e3,implementationCost:25e3,paybackPeriod:24,affectedAssets:M.filter(E=>E.category==="HVAC").map(E=>E.id),confidence:.87,actions:["Install smart thermostats","Upgrade building automation system","Implement demand-response controls"],timeline:"3-6 months",generatedAt:new Date},{id:`rec_${Date.now()}_2`,type:"PREDICTIVE_MAINTENANCE",title:"Implement Condition-Based Monitoring",description:"Deploy IoT sensors for real-time asset monitoring",priority:"MEDIUM",estimatedSavings:8e3,implementationCost:15e3,paybackPeriod:18,affectedAssets:M.filter(E=>E.criticality==="HIGH").map(E=>E.id),confidence:.92,actions:["Install vibration sensors","Deploy temperature monitoring","Set up data analytics platform"],timeline:"2-4 months",generatedAt:new Date}];return n.value.push(...S),S}catch(S){throw console.error("Failed to generate recommendations:",S),u.value="Failed to generate recommendations",S}finally{e.value=!1}},N=M=>{let S=100;const E=M.age||0;if(S-=Math.min(E*2,20),M.lastMaintenance){const l=Math.floor((new Date-new Date(M.lastMaintenance))/864e5);S-=Math.min(l*.1,15)}return S-={OPERATIONAL:0,MAINTENANCE:10,DOWN:30,DECOMMISSIONED:100}[M.status]||0,S*={LOW:1,MEDIUM:1.1,HIGH:1.2,CRITICAL:1.3}[M.criticality]||1,Math.max(0,Math.min(100,Math.round(S)))},w=M=>{const S=N(M),E=M.age||0,G=M.criticality||"LOW";let v=0;S<50?v+=40:S<70?v+=25:S<85&&(v+=10),E>15?v+=30:E>10?v+=20:E>5&&(v+=10),v*={CRITICAL:1.5,HIGH:1.3,MEDIUM:1.1,LOW:1}[G];const m=Math.min(100,Math.round(v));return m>=70?"HIGH":m>=40?"MEDIUM":"LOW"},T=(M,S,E,G)=>{t.value[M]={accuracy:S,precision:E,recall:G,f1Score:2*(E*G)/(E+G),lastUpdated:new Date}},_=()=>{i.value=[],s.value=[],n.value=[],o.value=[],u.value=null},F=()=>({predictions:i.value,anomalies:s.value,recommendations:n.value,performanceInsights:o.value,modelMetrics:t.value,exportedAt:new Date().toISOString()});return Ee(()=>{T(c.FAILURE_PREDICTION,.87,.85,.89),T(c.MAINTENANCE_OPTIMIZATION,.92,.9,.94),T(c.ANOMALY_DETECTION,.84,.88,.82),T(c.COST_FORECASTING,.79,.81,.78),T(c.PERFORMANCE_ANALYSIS,.91,.89,.93)}),{isProcessing:e,modelMetrics:t,predictions:i,anomalies:s,recommendations:n,performanceInsights:o,error:u,hasActivePredictions:d,criticalAnomalies:y,highPriorityRecommendations:A,AI_MODELS:c,predictAssetFailure:H,optimizeMaintenanceSchedule:b,detectAnomalies:P,forecastCosts:V,analyzePerformance:z,generateRecommendations:Y,calculateHealthScore:N,assessRisk:w,updateModelMetrics:T,clearAnalytics:_,exportAnalytics:F}}function ra(){const e=D(navigator.onLine),t=D([]),i=D(new Map),s=D(!1),n=D(null),o=D(null),u=X(()=>t.value.length>0),c=X(()=>s.value?"syncing":e.value?u.value?"pending":"synced":"offline"),d=X(()=>e.value&&!s.value),y={CACHED_ASSETS:"cmms_cached_assets",PENDING_ACTIONS:"cmms_pending_actions",LAST_SYNC:"cmms_last_sync",APP_VERSION:"cmms_app_version"},A={CREATE_ASSET:"CREATE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",DELETE_ASSET:"DELETE_ASSET",CREATE_WORK_ORDER:"CREATE_WORK_ORDER",UPDATE_MAINTENANCE:"UPDATE_MAINTENANCE",CONSUME_PART:"CONSUME_PART",UPDATE_VENDOR:"UPDATE_VENDOR"},H=()=>{try{const L=localStorage.getItem(y.PENDING_ACTIONS);L&&(t.value=JSON.parse(L));const h=localStorage.getItem(y.LAST_SYNC);h&&(n.value=new Date(h));const Q=localStorage.getItem(y.CACHED_ASSETS);if(Q){const Z=JSON.parse(Q);i.value=new Map(Object.entries(Z))}}catch(L){console.error("Failed to initialize offline storage:",L),o.value="Failed to initialize offline storage"}},b=()=>{try{localStorage.setItem(y.PENDING_ACTIONS,JSON.stringify(t.value));const L=Object.fromEntries(i.value);localStorage.setItem(y.CACHED_ASSETS,JSON.stringify(L)),n.value&&localStorage.setItem(y.LAST_SYNC,n.value.toISOString())}catch(L){console.error("Failed to save to storage:",L),o.value="Failed to save offline data"}},P=(L,h)=>{i.value.set(`asset_${L}`,{data:h,timestamp:new Date().toISOString(),type:"asset"}),b()},V=L=>{const h=i.value.get(`asset_${L}`);if(!h)return null;const Q=new Date(h.timestamp);return(new Date-Q)/(1e3*60*60)>24?(i.value.delete(`asset_${L}`),b(),null):h.data},z=(L,h,Q="normal")=>{const Z={id:Y(),type:L,data:h,timestamp:new Date().toISOString(),priority:Q,retryCount:0,maxRetries:3};return Q==="high"?t.value.unshift(Z):t.value.push(Z),b(),Z.id},Y=()=>`action_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,N=async()=>{if(!d.value||t.value.length===0)return{success:!0,processed:0,failed:0};s.value=!0;let L=0,h=0;try{const Q=[...t.value];for(const Z of Q)try{await w(Z);const ie=t.value.findIndex(ee=>ee.id===Z.id);ie!==-1&&t.value.splice(ie,1),L++}catch(ie){if(console.error("Failed to process action:",Z,ie),Z.retryCount++,Z.retryCount>=Z.maxRetries){const ee=t.value.findIndex(Ne=>Ne.id===Z.id);ee!==-1&&t.value.splice(ee,1)}h++}n.value=new Date,b()}catch(Q){console.error("Sync error:",Q),o.value="Sync failed"}finally{s.value=!1}return{success:!0,processed:L,failed:h}},w=async L=>{switch(L.type){case A.CREATE_ASSET:return await T(L.data);case A.UPDATE_ASSET:return await _(L.data);case A.DELETE_ASSET:return await F(L.data);case A.CREATE_WORK_ORDER:return await M(L.data);case A.UPDATE_MAINTENANCE:return await S(L.data);case A.CONSUME_PART:return await E(L.data);case A.UPDATE_VENDOR:return await G(L.data);default:throw new Error(`Unknown action type: ${L.type}`)}},T=async L=>(await new Promise(h=>setTimeout(h,1e3)),{success:!0,id:Date.now()}),_=async L=>(await new Promise(h=>setTimeout(h,1e3)),{success:!0}),F=async L=>(await new Promise(h=>setTimeout(h,1e3)),{success:!0}),M=async L=>(await new Promise(h=>setTimeout(h,1e3)),{success:!0,id:Date.now()}),S=async L=>(await new Promise(h=>setTimeout(h,1e3)),{success:!0}),E=async L=>(await new Promise(h=>setTimeout(h,1e3)),{success:!0}),G=async L=>(await new Promise(h=>setTimeout(h,1e3)),{success:!0}),v=()=>{t.value=[],b()},l=L=>{const h=t.value.findIndex(Q=>Q.id===L);h!==-1&&(t.value.splice(h,1),b())},m=()=>{try{let L=0;return Object.values(y).forEach(h=>{const Q=localStorage.getItem(h);Q&&(L+=new Blob([Q]).size)}),{used:L,usedMB:(L/(1024*1024)).toFixed(2),maxSize:5*1024*1024,percentage:(L/(5*1024*1024)*100).toFixed(1)}}catch{return{used:0,usedMB:"0",maxSize:0,percentage:"0"}}},g=()=>{i.value.clear(),Object.values(y).forEach(L=>{localStorage.removeItem(L)})},O=()=>({pendingActions:t.value,cachedData:Object.fromEntries(i.value),lastSyncTime:n.value,exportedAt:new Date().toISOString()}),U=L=>{try{return L.pendingActions&&(t.value=L.pendingActions),L.cachedData&&(i.value=new Map(Object.entries(L.cachedData))),L.lastSyncTime&&(n.value=new Date(L.lastSyncTime)),b(),!0}catch(h){return console.error("Failed to import offline data:",h),!1}},j=()=>{e.value=!0,u.value&&setTimeout(()=>{N()},1e3)},K=()=>{e.value=!1},re=L=>{"serviceWorker"in navigator&&"sync"in window.ServiceWorkerRegistration.prototype&&navigator.serviceWorker.ready.then(h=>h.sync.register(L)).catch(h=>{console.error("Background sync registration failed:",h)})};return Ee(()=>{H(),window.addEventListener("online",j),window.addEventListener("offline",K)}),Ln(()=>{window.removeEventListener("online",j),window.removeEventListener("offline",K)}),{isOnline:e,pendingActions:t,cachedData:i,syncInProgress:s,lastSyncTime:n,error:o,hasPendingActions:u,syncStatus:c,canSync:d,ACTION_TYPES:A,initializeOfflineStorage:H,cacheAssetData:P,getCachedAssetData:V,queueAction:z,syncPendingActions:N,clearPendingActions:v,removeAction:l,getStorageUsage:m,clearCache:g,exportOfflineData:O,importOfflineData:U,requestBackgroundSync:re}}function ia(){const e=D(!1),t=D([]),i=D([]),s=D([]),n=D([]),o=D([]),u=D([]),c=D(null),d={SAFETY:"SAFETY",ENVIRONMENTAL:"ENVIRONMENTAL",ENERGY:"ENERGY",FIRE:"FIRE",ACCESSIBILITY:"ACCESSIBILITY",BUILDING_CODE:"BUILDING_CODE",INSURANCE:"INSURANCE",ISO:"ISO",OSHA:"OSHA",EPA:"EPA"},y={COMPLIANT:"COMPLIANT",NON_COMPLIANT:"NON_COMPLIANT",PENDING:"PENDING",EXPIRED:"EXPIRED",EXPIRING_SOON:"EXPIRING_SOON"},A=X(()=>o.value.filter(l=>l.status==="OPEN")),H=X(()=>{const l=new Date;return l.setDate(l.getDate()+30),i.value.filter(m=>new Date(m.expiryDate)<=l&&m.status==="ACTIVE")}),b=X(()=>{if(t.value.length===0)return 0;const l=t.value.filter(m=>m.status===y.COMPLIANT).length;return Math.round(l/t.value.length*100)}),P=X(()=>u.value.filter(l=>l.priority==="CRITICAL"&&!l.dismissed)),V=async(l=null)=>{try{e.value=!0,await new Promise(g=>setTimeout(g,1e3));const m=[{id:1,assetId:l||1,category:d.FIRE,requirement:"Fire Safety Inspection",description:"Annual fire safety system inspection and certification",status:y.COMPLIANT,lastInspection:"2024-01-15",nextInspection:"2025-01-15",inspector:"City Fire Department",certificateNumber:"FS-2024-001",notes:"All systems operational, minor recommendations implemented"},{id:2,assetId:l||1,category:d.ELEVATOR,requirement:"Elevator Safety Inspection",description:"State-mandated elevator safety inspection",status:y.EXPIRING_SOON,lastInspection:"2024-02-20",nextInspection:"2024-08-20",inspector:"State Elevator Inspector",certificateNumber:"EL-2024-045",notes:"Certificate expires soon, schedule renewal inspection"},{id:3,assetId:l||1,category:d.ENVIRONMENTAL,requirement:"EPA Refrigerant Compliance",description:"EPA Section 608 refrigerant handling compliance",status:y.NON_COMPLIANT,lastInspection:"2023-06-10",nextInspection:"2024-06-10",inspector:"EPA Certified Technician",certificateNumber:"EPA-608-2023",notes:"Refrigerant leak detected, repair required for compliance"}];t.value=l?m.filter(g=>g.assetId===l):m}catch(m){console.error("Failed to load compliance data:",m),c.value="Failed to load compliance data"}finally{e.value=!1}},z=async(l=null)=>{try{const m=[{id:1,assetId:l||1,name:"HVAC Certification",issuingBody:"ASHRAE",certificateNumber:"ASHRAE-2024-HVAC-001",issueDate:"2024-01-15",expiryDate:"2025-01-15",status:"ACTIVE",renewalRequired:!0,renewalNotificationDays:60,cost:2500,attachments:["certificate.pdf","inspection_report.pdf"]},{id:2,assetId:l||2,name:"Elevator Operating License",issuingBody:"State Department of Labor",certificateNumber:"DOL-EL-2024-789",issueDate:"2024-02-20",expiryDate:"2024-08-20",status:"EXPIRING_SOON",renewalRequired:!0,renewalNotificationDays:30,cost:1200,attachments:["license.pdf"]}];i.value=l?m.filter(g=>g.assetId===l):m}catch(m){console.error("Failed to load certifications:",m),c.value="Failed to load certifications"}},Y=async(l,m)=>{try{e.value=!0,await new Promise(O=>setTimeout(O,1e3));const g=t.value.find(O=>O.id===l);return g&&(g.nextInspection=m,g.status=y.PENDING,F({type:"INSPECTION",message:`${g.requirement} scheduled for ${m}`,dueDate:m,priority:"HIGH",assetId:g.assetId})),!0}catch(g){return console.error("Failed to schedule inspection:",g),c.value="Failed to schedule inspection",!1}finally{e.value=!1}},N=async(l,m)=>{try{e.value=!0;const g=t.value.find(O=>O.id===l);return g&&(g.lastInspection=m.inspectionDate,g.status=m.passed?y.COMPLIANT:y.NON_COMPLIANT,g.inspector=m.inspector,g.notes=m.notes,m.nextInspectionDate&&(g.nextInspection=m.nextInspectionDate),m.certificateNumber&&(g.certificateNumber=m.certificateNumber),m.passed||o.value.push({id:Date.now(),complianceRecordId:l,assetId:g.assetId,category:g.category,violation:m.violations||["Inspection failed"],severity:m.severity||"MEDIUM",status:"OPEN",discoveredDate:m.inspectionDate,description:m.notes,correctiveActions:m.correctiveActions||[]})),!0}catch(g){return console.error("Failed to record inspection result:",g),c.value="Failed to record inspection result",!1}finally{e.value=!1}},w=async(l,m)=>{try{e.value=!0;const g=i.value.find(O=>O.id===l);return g&&(g.issueDate=m.issueDate,g.expiryDate=m.expiryDate,g.certificateNumber=m.certificateNumber||g.certificateNumber,g.status="ACTIVE",g.cost=m.cost||g.cost,m.attachments&&g.attachments.push(...m.attachments),u.value=u.value.filter(O=>!(O.type==="CERTIFICATION_RENEWAL"&&O.certificationId===l))),!0}catch(g){return console.error("Failed to renew certification:",g),c.value="Failed to renew certification",!1}finally{e.value=!1}},T=l=>{const m={id:Date.now(),assetId:l.assetId,category:l.category,violation:l.violation,severity:l.severity||"MEDIUM",status:"OPEN",discoveredDate:new Date().toISOString(),description:l.description||"",correctiveActions:l.correctiveActions||[],dueDate:l.dueDate,assignedTo:l.assignedTo,estimatedCost:l.estimatedCost||0};return o.value.push(m),(m.severity==="HIGH"||m.severity==="CRITICAL")&&F({type:"VIOLATION",message:`Critical compliance violation: ${m.violation}`,dueDate:m.dueDate,priority:"CRITICAL",assetId:m.assetId,violationId:m.id}),m},_=async(l,m)=>{try{const g=o.value.find(O=>O.id===l);return g&&(g.status="RESOLVED",g.resolvedDate=new Date().toISOString(),g.resolution=m.resolution,g.resolvedBy=m.resolvedBy,g.actualCost=m.actualCost,u.value=u.value.filter(O=>O.violationId!==l)),!0}catch(g){return console.error("Failed to resolve violation:",g),c.value="Failed to resolve violation",!1}},F=l=>{const m={id:Date.now(),type:l.type,message:l.message,dueDate:l.dueDate,priority:l.priority||"MEDIUM",assetId:l.assetId,dismissed:!1,createdAt:new Date().toISOString(),...l};return u.value.push(m),m},M=l=>{const m=u.value.find(g=>g.id===l);m&&(m.dismissed=!0,m.dismissedAt=new Date().toISOString())},S=async(l=[],m=null)=>{try{e.value=!0,await new Promise(U=>setTimeout(U,1500));const g=l.length>0?t.value.filter(U=>l.includes(U.assetId)):t.value,O={generatedAt:new Date().toISOString(),dateRange:m,summary:{totalRecords:g.length,compliant:g.filter(U=>U.status===y.COMPLIANT).length,nonCompliant:g.filter(U=>U.status===y.NON_COMPLIANT).length,pending:g.filter(U=>U.status===y.PENDING).length,expiring:g.filter(U=>U.status===y.EXPIRING_SOON).length},complianceScore:b.value,byCategory:{},violations:A.value,upcomingRenewals:H.value,recommendations:["Schedule immediate inspection for expired certifications","Implement preventive maintenance for critical assets","Review compliance procedures quarterly","Train staff on regulatory requirements"]};return Object.values(d).forEach(U=>{const j=g.filter(K=>K.category===U);j.length>0&&(O.byCategory[U]={total:j.length,compliant:j.filter(K=>K.status===y.COMPLIANT).length,nonCompliant:j.filter(K=>K.status===y.NON_COMPLIANT).length,score:Math.round(j.filter(K=>K.status===y.COMPLIANT).length/j.length*100)})}),O}catch(g){return console.error("Failed to generate compliance report:",g),c.value="Failed to generate compliance report",null}finally{e.value=!1}},E=async()=>{try{await new Promise(m=>setTimeout(m,1e3));const l=[{regulation:"OSHA Safety Standards",category:d.SAFETY,effectiveDate:"2024-07-01",description:"Updated workplace safety requirements for industrial equipment",impact:"MEDIUM",actionRequired:"Review safety procedures and update documentation"},{regulation:"EPA Refrigerant Regulations",category:d.ENVIRONMENTAL,effectiveDate:"2024-09-01",description:"New reporting requirements for refrigerant usage",impact:"LOW",actionRequired:"Update reporting procedures"}];return n.value.push(...l),l.forEach(m=>{(m.impact==="HIGH"||m.impact==="CRITICAL")&&F({type:"REGULATORY_UPDATE",message:`New regulation: ${m.regulation}`,dueDate:m.effectiveDate,priority:m.impact==="CRITICAL"?"CRITICAL":"HIGH",regulation:m.regulation})}),l}catch(l){return console.error("Failed to check regulatory updates:",l),c.value="Failed to check regulatory updates",[]}},G=()=>({complianceRecords:t.value,certifications:i.value,violations:o.value,reminders:u.value,complianceScore:b.value,exportedAt:new Date().toISOString()}),v=()=>{const l=new Date;i.value.forEach(m=>{const g=new Date(m.expiryDate),O=Math.ceil((g-l)/(1e3*60*60*24));O<=m.renewalNotificationDays&&m.status==="ACTIVE"&&(m.status="EXPIRING_SOON",u.value.find(j=>j.type==="CERTIFICATION_RENEWAL"&&j.certificationId===m.id)||F({type:"CERTIFICATION_RENEWAL",message:`${m.name} expires in ${O} days`,dueDate:m.expiryDate,priority:O<=7?"CRITICAL":"HIGH",assetId:m.assetId,certificationId:m.id}))}),t.value.forEach(m=>{m.nextInspection&&new Date(m.nextInspection)<l&&m.status!==y.NON_COMPLIANT&&(m.status=y.EXPIRED,F({type:"OVERDUE_INSPECTION",message:`${m.requirement} is overdue`,dueDate:m.nextInspection,priority:"CRITICAL",assetId:m.assetId,complianceRecordId:m.id}))})};return Ee(()=>{v(),setInterval(v,60*60*1e3)}),{loading:e,complianceRecords:t,certifications:i,audits:s,regulations:n,violations:o,reminders:u,error:c,activeViolations:A,upcomingRenewals:H,complianceScore:b,criticalReminders:P,COMPLIANCE_CATEGORIES:d,COMPLIANCE_STATUS:y,loadComplianceData:V,loadCertifications:z,scheduleInspection:Y,recordInspectionResult:N,renewCertification:w,createViolation:T,resolveViolation:_,createReminder:F,dismissReminder:M,generateComplianceReport:S,checkRegulatoryUpdates:E,exportComplianceData:G,performComplianceCheck:v}}const la={class:"asset-id-generator"},ca={class:"mb-4 p-4 bg-green-50 border border-green-200 rounded-lg"},ua={class:"flex items-center justify-between"},da={class:"text-lg font-bold text-green-900 font-mono"},ma={class:"flex items-center space-x-2"},fa={key:0,class:"mb-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg"},ga={class:"flex items-center space-x-3"},va={key:1,class:"mb-4 p-4 bg-gray-50 border border-gray-200 rounded-lg"},pa={class:"grid grid-cols-1 md:grid-cols-3 gap-4"},ha={class:"mt-3 flex items-center justify-between"},ya={class:"text-xs text-gray-500"},wa={class:"font-mono font-bold"},Ca={class:"flex space-x-2"},Aa={key:2,class:"mt-2 text-sm text-red-600"},ba={__name:"AssetIdGenerator",props:{modelValue:{type:String,default:""},disabled:{type:Boolean,default:!1},error:{type:String,default:null}},emits:["update:modelValue"],setup(e,{expose:t,emit:i}){const s=e,n=i,o=D(""),u=D(""),c=D(!1),d=D(!1),y=D(!1),A=D("AST"),H=D("TIMESTAMP"),b=D(3),P=[{value:"TIMESTAMP",label:"Timestamp"},{value:"YYYYMMDD",label:"YYYY-MM-DD"},{value:"YYMMDD",label:"YY-MM-DD"},{value:"YYYY",label:"Year Only"}],V=[{value:2,label:"2 chars"},{value:3,label:"3 chars"},{value:4,label:"4 chars"},{value:5,label:"5 chars"}],z=X(()=>!y.value),Y=X(()=>N(A.value,H.value,b.value)),N=(v,l,m)=>{let g="";const O=new Date;switch(l){case"TIMESTAMP":g=Date.now().toString().slice(-6);break;case"YYYYMMDD":g=O.toISOString().slice(0,10).replace(/-/g,"");break;case"YYMMDD":g=O.toISOString().slice(2,10).replace(/-/g,"");break;case"YYYY":g=O.getFullYear().toString();break}const U=Math.random().toString(36).substring(2,2+m).toUpperCase();return`${v}-${g}-${U}`},w=()=>{const v=N(A.value,H.value,b.value);o.value=v,y.value=!1,n("update:modelValue",v)},T=()=>{y.value||w()},_=()=>{d.value=!d.value,d.value||(c.value=!1)},F=()=>{u.value.trim()&&(o.value=u.value.trim(),y.value=!0,c.value=!1,d.value=!1,n("update:modelValue",u.value.trim()))},M=()=>{u.value="",c.value=!1},S=()=>{},E=()=>{w(),d.value=!1},G=()=>{A.value="AST",H.value="TIMESTAMP",b.value=3};return tt(()=>d.value,v=>{v&&(c.value=!0)}),tt(()=>s.modelValue,v=>{v!==o.value&&(o.value=v)}),Ee(()=>{s.modelValue?(o.value=s.modelValue,y.value=!0):w()}),t({generateId:w,regenerateId:T}),(v,l)=>(k(),R("div",la,[r("div",ca,[r("div",ua,[r("div",null,[l[4]||(l[4]=r("h4",{class:"text-sm font-medium text-green-900"},"Asset ID",-1)),r("p",da,$(o.value||"Auto-generated"),1)]),r("div",ma,[x(C(J),{variant:"outline",size:"sm",onClick:T,disabled:e.disabled||!z.value},{default:B(()=>l[5]||(l[5]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1),q(" Regenerate ",-1)])),_:1,__:[5]},8,["disabled"]),x(C(J),{variant:"ghost",size:"sm",onClick:_},{default:B(()=>l[6]||(l[6]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1),q(" Customize ",-1)])),_:1,__:[6]})])])]),c.value?(k(),R("div",fa,[l[9]||(l[9]=r("h4",{class:"text-sm font-medium text-yellow-900 mb-2"},"Manual ID Entry",-1)),r("div",ga,[x(C(oe),{modelValue:u.value,"onUpdate:modelValue":l[0]||(l[0]=m=>u.value=m),placeholder:"Enter custom asset ID...",disabled:e.disabled,class:"flex-1"},null,8,["modelValue","disabled"]),x(C(J),{onClick:F,disabled:!u.value||e.disabled},{default:B(()=>l[7]||(l[7]=[q(" Use ID ",-1)])),_:1,__:[7]},8,["disabled"]),x(C(J),{variant:"ghost",onClick:M},{default:B(()=>l[8]||(l[8]=[q(" Cancel ",-1)])),_:1,__:[8]})]),l[10]||(l[10]=r("p",{class:"text-xs text-yellow-700 mt-2"}," Enter a custom asset ID according to your company's asset register format ",-1))])):W("",!0),d.value?(k(),R("div",va,[l[17]||(l[17]=r("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"ID Format Customization",-1)),r("div",pa,[r("div",null,[l[11]||(l[11]=r("label",{class:"block text-xs font-medium text-gray-600 mb-1"},"Prefix",-1)),x(C(oe),{modelValue:A.value,"onUpdate:modelValue":l[1]||(l[1]=m=>A.value=m),placeholder:"AST",disabled:e.disabled,onInput:S},null,8,["modelValue","disabled"])]),r("div",null,[l[12]||(l[12]=r("label",{class:"block text-xs font-medium text-gray-600 mb-1"},"Date Format",-1)),x(C(ce),{modelValue:H.value,"onUpdate:modelValue":l[2]||(l[2]=m=>H.value=m),options:P,disabled:e.disabled,onChange:S},null,8,["modelValue","disabled"])]),r("div",null,[l[13]||(l[13]=r("label",{class:"block text-xs font-medium text-gray-600 mb-1"},"Suffix Length",-1)),x(C(ce),{modelValue:b.value,"onUpdate:modelValue":l[3]||(l[3]=m=>b.value=m),options:V,disabled:e.disabled,onChange:S},null,8,["modelValue","disabled"])])]),r("div",ha,[r("p",ya,[l[14]||(l[14]=q(" Preview: ",-1)),r("span",wa,$(Y.value),1)]),r("div",Ca,[x(C(J),{size:"sm",onClick:E},{default:B(()=>l[15]||(l[15]=[q("Apply",-1)])),_:1,__:[15]}),x(C(J),{size:"sm",variant:"ghost",onClick:G},{default:B(()=>l[16]||(l[16]=[q("Reset",-1)])),_:1,__:[16]})])])])):W("",!0),e.error?(k(),R("div",Aa,$(e.error),1)):W("",!0)]))}},Ia=rt(ba,[["__scopeId","data-v-11fdeccb"]]);var Me={},Ea=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Bt={},ae={};let it;const Ma=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];ae.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};ae.getSymbolTotalCodewords=function(t){return Ma[t]};ae.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};ae.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');it=t};ae.isKanjiModeEnabled=function(){return typeof it<"u"};ae.toSJIS=function(t){return it(t)};var Le={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,n){if(e.isValid(s))return s;try{return t(s)}catch{return n}}})(Le);function Vt(){this.buffer=[],this.length=0}Vt.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let i=0;i<t;i++)this.putBit((e>>>t-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Sa=Vt;function Se(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Se.prototype.set=function(e,t,i,s){const n=e*this.size+t;this.data[n]=i,s&&(this.reservedBit[n]=!0)};Se.prototype.get=function(e,t){return this.data[e*this.size+t]};Se.prototype.xor=function(e,t,i){this.data[e*this.size+t]^=i};Se.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Na=Se,Ut={};(function(e){const t=ae.getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const n=Math.floor(s/7)+2,o=t(s),u=o===145?26:Math.ceil((o-13)/(2*n-2))*2,c=[o-7];for(let d=1;d<n-1;d++)c[d]=c[d-1]-u;return c.push(6),c.reverse()},e.getPositions=function(s){const n=[],o=e.getRowColCoords(s),u=o.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c===0&&d===0||c===0&&d===u-1||c===u-1&&d===0||n.push([o[c],o[d]]);return n}})(Ut);var zt={};const ka=ae.getSymbolSize,Ot=7;zt.getPositions=function(t){const i=ka(t);return[[0,0],[i-Ot,0],[0,i-Ot]]};var Ht={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},e.from=function(n){return e.isValid(n)?parseInt(n,10):void 0},e.getPenaltyN1=function(n){const o=n.size;let u=0,c=0,d=0,y=null,A=null;for(let H=0;H<o;H++){c=d=0,y=A=null;for(let b=0;b<o;b++){let P=n.get(H,b);P===y?c++:(c>=5&&(u+=t.N1+(c-5)),y=P,c=1),P=n.get(b,H),P===A?d++:(d>=5&&(u+=t.N1+(d-5)),A=P,d=1)}c>=5&&(u+=t.N1+(c-5)),d>=5&&(u+=t.N1+(d-5))}return u},e.getPenaltyN2=function(n){const o=n.size;let u=0;for(let c=0;c<o-1;c++)for(let d=0;d<o-1;d++){const y=n.get(c,d)+n.get(c,d+1)+n.get(c+1,d)+n.get(c+1,d+1);(y===4||y===0)&&u++}return u*t.N2},e.getPenaltyN3=function(n){const o=n.size;let u=0,c=0,d=0;for(let y=0;y<o;y++){c=d=0;for(let A=0;A<o;A++)c=c<<1&2047|n.get(y,A),A>=10&&(c===1488||c===93)&&u++,d=d<<1&2047|n.get(A,y),A>=10&&(d===1488||d===93)&&u++}return u*t.N3},e.getPenaltyN4=function(n){let o=0;const u=n.data.length;for(let d=0;d<u;d++)o+=n.data[d];return Math.abs(Math.ceil(o*100/u/5)-10)*t.N4};function i(s,n,o){switch(s){case e.Patterns.PATTERN000:return(n+o)%2===0;case e.Patterns.PATTERN001:return n%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(n+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return n*o%2+n*o%3===0;case e.Patterns.PATTERN110:return(n*o%2+n*o%3)%2===0;case e.Patterns.PATTERN111:return(n*o%3+(n+o)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(n,o){const u=o.size;for(let c=0;c<u;c++)for(let d=0;d<u;d++)o.isReserved(d,c)||o.xor(d,c,i(n,d,c))},e.getBestMask=function(n,o){const u=Object.keys(e.Patterns).length;let c=0,d=1/0;for(let y=0;y<u;y++){o(y),e.applyMask(y,n);const A=e.getPenaltyN1(n)+e.getPenaltyN2(n)+e.getPenaltyN3(n)+e.getPenaltyN4(n);e.applyMask(y,n),A<d&&(d=A,c=y)}return c}})(Ht);var Fe={};const ue=Le,_e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Re=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Fe.getBlocksCount=function(t,i){switch(i){case ue.L:return _e[(t-1)*4+0];case ue.M:return _e[(t-1)*4+1];case ue.Q:return _e[(t-1)*4+2];case ue.H:return _e[(t-1)*4+3];default:return}};Fe.getTotalCodewordsCount=function(t,i){switch(i){case ue.L:return Re[(t-1)*4+0];case ue.M:return Re[(t-1)*4+1];case ue.Q:return Re[(t-1)*4+2];case ue.H:return Re[(t-1)*4+3];default:return}};var $t={},Be={};const be=new Uint8Array(512),Pe=new Uint8Array(256);(function(){let t=1;for(let i=0;i<255;i++)be[i]=t,Pe[t]=i,t<<=1,t&256&&(t^=285);for(let i=255;i<512;i++)be[i]=be[i-255]})();Be.log=function(t){if(t<1)throw new Error("log("+t+")");return Pe[t]};Be.exp=function(t){return be[t]};Be.mul=function(t,i){return t===0||i===0?0:be[Pe[t]+Pe[i]]};(function(e){const t=Be;e.mul=function(s,n){const o=new Uint8Array(s.length+n.length-1);for(let u=0;u<s.length;u++)for(let c=0;c<n.length;c++)o[u+c]^=t.mul(s[u],n[c]);return o},e.mod=function(s,n){let o=new Uint8Array(s);for(;o.length-n.length>=0;){const u=o[0];for(let d=0;d<n.length;d++)o[d]^=t.mul(n[d],u);let c=0;for(;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},e.generateECPolynomial=function(s){let n=new Uint8Array([1]);for(let o=0;o<s;o++)n=e.mul(n,new Uint8Array([1,t.exp(o)]));return n}})($t);const jt=$t;function lt(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}lt.prototype.initialize=function(t){this.degree=t,this.genPoly=jt.generateECPolynomial(this.degree)};lt.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const i=new Uint8Array(t.length+this.degree);i.set(t);const s=jt.mod(i,this.genPoly),n=this.degree-s.length;if(n>0){const o=new Uint8Array(this.degree);return o.set(s,n),o}return s};var Ta=lt,Yt={},de={},ct={};ct.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var se={};const Gt="[0-9]+",xa="[A-Z $%*+\\-./:]+";let Ie="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ie=Ie.replace(/u/g,"\\u");const _a="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ie+`)(?:.|[\r
|
||
]))+`;se.KANJI=new RegExp(Ie,"g");se.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");se.BYTE=new RegExp(_a,"g");se.NUMERIC=new RegExp(Gt,"g");se.ALPHANUMERIC=new RegExp(xa,"g");const Ra=new RegExp("^"+Ie+"$"),Da=new RegExp("^"+Gt+"$"),Pa=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");se.testKanji=function(t){return Ra.test(t)};se.testNumeric=function(t){return Da.test(t)};se.testAlphanumeric=function(t){return Pa.test(t)};(function(e){const t=ct,i=se;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(o,u){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?o.ccBits[0]:u<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return i.testNumeric(o)?e.NUMERIC:i.testAlphanumeric(o)?e.ALPHANUMERIC:i.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.ccBits};function s(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+n)}}e.from=function(o,u){if(e.isValid(o))return o;try{return s(o)}catch{return u}}})(de);(function(e){const t=ae,i=Fe,s=Le,n=de,o=ct,u=7973,c=t.getBCHDigit(u);function d(b,P,V){for(let z=1;z<=40;z++)if(P<=e.getCapacity(z,V,b))return z}function y(b,P){return n.getCharCountIndicator(b,P)+4}function A(b,P){let V=0;return b.forEach(function(z){const Y=y(z.mode,P);V+=Y+z.getBitsLength()}),V}function H(b,P){for(let V=1;V<=40;V++)if(A(b,V)<=e.getCapacity(V,P,n.MIXED))return V}e.from=function(P,V){return o.isValid(P)?parseInt(P,10):V},e.getCapacity=function(P,V,z){if(!o.isValid(P))throw new Error("Invalid QR Code version");typeof z>"u"&&(z=n.BYTE);const Y=t.getSymbolTotalCodewords(P),N=i.getTotalCodewordsCount(P,V),w=(Y-N)*8;if(z===n.MIXED)return w;const T=w-y(z,P);switch(z){case n.NUMERIC:return Math.floor(T/10*3);case n.ALPHANUMERIC:return Math.floor(T/11*2);case n.KANJI:return Math.floor(T/13);case n.BYTE:default:return Math.floor(T/8)}},e.getBestVersionForData=function(P,V){let z;const Y=s.from(V,s.M);if(Array.isArray(P)){if(P.length>1)return H(P,Y);if(P.length===0)return 1;z=P[0]}else z=P;return d(z.mode,z.getLength(),Y)},e.getEncodedBits=function(P){if(!o.isValid(P)||P<7)throw new Error("Invalid QR Code version");let V=P<<12;for(;t.getBCHDigit(V)-c>=0;)V^=u<<t.getBCHDigit(V)-c;return P<<12|V}})(Yt);var qt={};const nt=ae,Qt=1335,Oa=21522,Lt=nt.getBCHDigit(Qt);qt.getEncodedBits=function(t,i){const s=t.bit<<3|i;let n=s<<10;for(;nt.getBCHDigit(n)-Lt>=0;)n^=Qt<<nt.getBCHDigit(n)-Lt;return(s<<10|n)^Oa};var Wt={};const La=de;function pe(e){this.mode=La.NUMERIC,this.data=e.toString()}pe.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};pe.prototype.getLength=function(){return this.data.length};pe.prototype.getBitsLength=function(){return pe.getBitsLength(this.data.length)};pe.prototype.write=function(t){let i,s,n;for(i=0;i+3<=this.data.length;i+=3)s=this.data.substr(i,3),n=parseInt(s,10),t.put(n,10);const o=this.data.length-i;o>0&&(s=this.data.substr(i),n=parseInt(s,10),t.put(n,o*3+1))};var Fa=pe;const Ba=de,Je=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function he(e){this.mode=Ba.ALPHANUMERIC,this.data=e}he.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};he.prototype.getLength=function(){return this.data.length};he.prototype.getBitsLength=function(){return he.getBitsLength(this.data.length)};he.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let s=Je.indexOf(this.data[i])*45;s+=Je.indexOf(this.data[i+1]),t.put(s,11)}this.data.length%2&&t.put(Je.indexOf(this.data[i]),6)};var Va=he;const Ua=de;function ye(e){this.mode=Ua.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}ye.getBitsLength=function(t){return t*8};ye.prototype.getLength=function(){return this.data.length};ye.prototype.getBitsLength=function(){return ye.getBitsLength(this.data.length)};ye.prototype.write=function(e){for(let t=0,i=this.data.length;t<i;t++)e.put(this.data[t],8)};var za=ye;const Ha=de,$a=ae;function we(e){this.mode=Ha.KANJI,this.data=e}we.getBitsLength=function(t){return t*13};we.prototype.getLength=function(){return this.data.length};we.prototype.getBitsLength=function(){return we.getBitsLength(this.data.length)};we.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let i=$a.toSJIS(this.data[t]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
||
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),e.put(i,13)}};var ja=we,Jt={exports:{}};(function(e){var t={single_source_shortest_paths:function(i,s,n){var o={},u={};u[s]=0;var c=t.PriorityQueue.make();c.push(s,0);for(var d,y,A,H,b,P,V,z,Y;!c.empty();){d=c.pop(),y=d.value,H=d.cost,b=i[y]||{};for(A in b)b.hasOwnProperty(A)&&(P=b[A],V=H+P,z=u[A],Y=typeof u[A]>"u",(Y||z>V)&&(u[A]=V,c.push(A,V),o[A]=y))}if(typeof n<"u"&&typeof u[n]>"u"){var N=["Could not find a path from ",s," to ",n,"."].join("");throw new Error(N)}return o},extract_shortest_path_from_predecessor_list:function(i,s){for(var n=[],o=s;o;)n.push(o),i[o],o=i[o];return n.reverse(),n},find_path:function(i,s,n){var o=t.single_source_shortest_paths(i,s,n);return t.extract_shortest_path_from_predecessor_list(o,n)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,n={},o;i=i||{};for(o in s)s.hasOwnProperty(o)&&(n[o]=s[o]);return n.queue=[],n.sorter=i.sorter||s.default_sorter,n},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var n={value:i,cost:s};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Jt);var Ya=Jt.exports;(function(e){const t=de,i=Fa,s=Va,n=za,o=ja,u=se,c=ae,d=Ya;function y(N){return unescape(encodeURIComponent(N)).length}function A(N,w,T){const _=[];let F;for(;(F=N.exec(T))!==null;)_.push({data:F[0],index:F.index,mode:w,length:F[0].length});return _}function H(N){const w=A(u.NUMERIC,t.NUMERIC,N),T=A(u.ALPHANUMERIC,t.ALPHANUMERIC,N);let _,F;return c.isKanjiModeEnabled()?(_=A(u.BYTE,t.BYTE,N),F=A(u.KANJI,t.KANJI,N)):(_=A(u.BYTE_KANJI,t.BYTE,N),F=[]),w.concat(T,_,F).sort(function(S,E){return S.index-E.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function b(N,w){switch(w){case t.NUMERIC:return i.getBitsLength(N);case t.ALPHANUMERIC:return s.getBitsLength(N);case t.KANJI:return o.getBitsLength(N);case t.BYTE:return n.getBitsLength(N)}}function P(N){return N.reduce(function(w,T){const _=w.length-1>=0?w[w.length-1]:null;return _&&_.mode===T.mode?(w[w.length-1].data+=T.data,w):(w.push(T),w)},[])}function V(N){const w=[];for(let T=0;T<N.length;T++){const _=N[T];switch(_.mode){case t.NUMERIC:w.push([_,{data:_.data,mode:t.ALPHANUMERIC,length:_.length},{data:_.data,mode:t.BYTE,length:_.length}]);break;case t.ALPHANUMERIC:w.push([_,{data:_.data,mode:t.BYTE,length:_.length}]);break;case t.KANJI:w.push([_,{data:_.data,mode:t.BYTE,length:y(_.data)}]);break;case t.BYTE:w.push([{data:_.data,mode:t.BYTE,length:y(_.data)}])}}return w}function z(N,w){const T={},_={start:{}};let F=["start"];for(let M=0;M<N.length;M++){const S=N[M],E=[];for(let G=0;G<S.length;G++){const v=S[G],l=""+M+G;E.push(l),T[l]={node:v,lastCount:0},_[l]={};for(let m=0;m<F.length;m++){const g=F[m];T[g]&&T[g].node.mode===v.mode?(_[g][l]=b(T[g].lastCount+v.length,v.mode)-b(T[g].lastCount,v.mode),T[g].lastCount+=v.length):(T[g]&&(T[g].lastCount=v.length),_[g][l]=b(v.length,v.mode)+4+t.getCharCountIndicator(v.mode,w))}}F=E}for(let M=0;M<F.length;M++)_[F[M]].end=0;return{map:_,table:T}}function Y(N,w){let T;const _=t.getBestModeForData(N);if(T=t.from(w,_),T!==t.BYTE&&T.bit<_.bit)throw new Error('"'+N+'" cannot be encoded with mode '+t.toString(T)+`.
|
||
Suggested mode is: `+t.toString(_));switch(T===t.KANJI&&!c.isKanjiModeEnabled()&&(T=t.BYTE),T){case t.NUMERIC:return new i(N);case t.ALPHANUMERIC:return new s(N);case t.KANJI:return new o(N);case t.BYTE:return new n(N)}}e.fromArray=function(w){return w.reduce(function(T,_){return typeof _=="string"?T.push(Y(_,null)):_.data&&T.push(Y(_.data,_.mode)),T},[])},e.fromString=function(w,T){const _=H(w,c.isKanjiModeEnabled()),F=V(_),M=z(F,T),S=d.find_path(M.map,"start","end"),E=[];for(let G=1;G<S.length-1;G++)E.push(M.table[S[G]].node);return e.fromArray(P(E))},e.rawSplit=function(w){return e.fromArray(H(w,c.isKanjiModeEnabled()))}})(Wt);const Ve=ae,Ke=Le,Ga=Sa,qa=Na,Qa=Ut,Wa=zt,at=Ht,ot=Fe,Ja=Ta,Oe=Yt,Ka=qt,Xa=de,Xe=Wt;function Za(e,t){const i=e.size,s=Wa.getPositions(t);for(let n=0;n<s.length;n++){const o=s[n][0],u=s[n][1];for(let c=-1;c<=7;c++)if(!(o+c<=-1||i<=o+c))for(let d=-1;d<=7;d++)u+d<=-1||i<=u+d||(c>=0&&c<=6&&(d===0||d===6)||d>=0&&d<=6&&(c===0||c===6)||c>=2&&c<=4&&d>=2&&d<=4?e.set(o+c,u+d,!0,!0):e.set(o+c,u+d,!1,!0))}}function eo(e){const t=e.size;for(let i=8;i<t-8;i++){const s=i%2===0;e.set(i,6,s,!0),e.set(6,i,s,!0)}}function to(e,t){const i=Qa.getPositions(t);for(let s=0;s<i.length;s++){const n=i[s][0],o=i[s][1];for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)u===-2||u===2||c===-2||c===2||u===0&&c===0?e.set(n+u,o+c,!0,!0):e.set(n+u,o+c,!1,!0)}}function no(e,t){const i=e.size,s=Oe.getEncodedBits(t);let n,o,u;for(let c=0;c<18;c++)n=Math.floor(c/3),o=c%3+i-8-3,u=(s>>c&1)===1,e.set(n,o,u,!0),e.set(o,n,u,!0)}function Ze(e,t,i){const s=e.size,n=Ka.getEncodedBits(t,i);let o,u;for(o=0;o<15;o++)u=(n>>o&1)===1,o<6?e.set(o,8,u,!0):o<8?e.set(o+1,8,u,!0):e.set(s-15+o,8,u,!0),o<8?e.set(8,s-o-1,u,!0):o<9?e.set(8,15-o-1+1,u,!0):e.set(8,15-o-1,u,!0);e.set(s-8,8,1,!0)}function ao(e,t){const i=e.size;let s=-1,n=i-1,o=7,u=0;for(let c=i-1;c>0;c-=2)for(c===6&&c--;;){for(let d=0;d<2;d++)if(!e.isReserved(n,c-d)){let y=!1;u<t.length&&(y=(t[u]>>>o&1)===1),e.set(n,c-d,y),o--,o===-1&&(u++,o=7)}if(n+=s,n<0||i<=n){n-=s,s=-s;break}}}function oo(e,t,i){const s=new Ga;i.forEach(function(d){s.put(d.mode.bit,4),s.put(d.getLength(),Xa.getCharCountIndicator(d.mode,e)),d.write(s)});const n=Ve.getSymbolTotalCodewords(e),o=ot.getTotalCodewordsCount(e,t),u=(n-o)*8;for(s.getLengthInBits()+4<=u&&s.put(0,4);s.getLengthInBits()%8!==0;)s.putBit(0);const c=(u-s.getLengthInBits())/8;for(let d=0;d<c;d++)s.put(d%2?17:236,8);return so(s,e,t)}function so(e,t,i){const s=Ve.getSymbolTotalCodewords(t),n=ot.getTotalCodewordsCount(t,i),o=s-n,u=ot.getBlocksCount(t,i),c=s%u,d=u-c,y=Math.floor(s/u),A=Math.floor(o/u),H=A+1,b=y-A,P=new Ja(b);let V=0;const z=new Array(u),Y=new Array(u);let N=0;const w=new Uint8Array(e.buffer);for(let S=0;S<u;S++){const E=S<d?A:H;z[S]=w.slice(V,V+E),Y[S]=P.encode(z[S]),V+=E,N=Math.max(N,E)}const T=new Uint8Array(s);let _=0,F,M;for(F=0;F<N;F++)for(M=0;M<u;M++)F<z[M].length&&(T[_++]=z[M][F]);for(F=0;F<b;F++)for(M=0;M<u;M++)T[_++]=Y[M][F];return T}function ro(e,t,i,s){let n;if(Array.isArray(e))n=Xe.fromArray(e);else if(typeof e=="string"){let y=t;if(!y){const A=Xe.rawSplit(e);y=Oe.getBestVersionForData(A,i)}n=Xe.fromString(e,y||40)}else throw new Error("Invalid data");const o=Oe.getBestVersionForData(n,i);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`
|
||
The chosen QR Code version cannot contain this amount of data.
|
||
Minimum version required to store current data is: `+o+`.
|
||
`);const u=oo(t,i,n),c=Ve.getSymbolSize(t),d=new qa(c);return Za(d,t),eo(d),to(d,t),Ze(d,i,0),t>=7&&no(d,t),ao(d,u),isNaN(s)&&(s=at.getBestMask(d,Ze.bind(null,d,i))),at.applyMask(s,d),Ze(d,i,s),{modules:d,version:t,errorCorrectionLevel:i,maskPattern:s,segments:n}}Bt.create=function(t,i){if(typeof t>"u"||t==="")throw new Error("No input text");let s=Ke.M,n,o;return typeof i<"u"&&(s=Ke.from(i.errorCorrectionLevel,Ke.M),n=Oe.from(i.version),o=at.from(i.maskPattern),i.toSJISFunc&&Ve.setToSJISFunction(i.toSJISFunc)),ro(t,n,s,o)};var Kt={},ut={};(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(o){return[o,o]}))),s.length===6&&s.push("F","F");const n=parseInt(s.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const n=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,o=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:o,scale:o?4:u,margin:n,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,n){return n.width&&n.width>=s+n.margin*2?n.width/(s+n.margin*2):n.scale},e.getImageWidth=function(s,n){const o=e.getScale(s,n);return Math.floor((s+n.margin*2)*o)},e.qrToImageData=function(s,n,o){const u=n.modules.size,c=n.modules.data,d=e.getScale(u,o),y=Math.floor((u+o.margin*2)*d),A=o.margin*d,H=[o.color.light,o.color.dark];for(let b=0;b<y;b++)for(let P=0;P<y;P++){let V=(b*y+P)*4,z=o.color.light;if(b>=A&&P>=A&&b<y-A&&P<y-A){const Y=Math.floor((b-A)/d),N=Math.floor((P-A)/d);z=H[c[Y*u+N]?1:0]}s[V++]=z.r,s[V++]=z.g,s[V++]=z.b,s[V]=z.a}}})(ut);(function(e){const t=ut;function i(n,o,u){n.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=u,o.width=u,o.style.height=u+"px",o.style.width=u+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,u,c){let d=c,y=u;typeof d>"u"&&(!u||!u.getContext)&&(d=u,u=void 0),u||(y=s()),d=t.getOptions(d);const A=t.getImageWidth(o.modules.size,d),H=y.getContext("2d"),b=H.createImageData(A,A);return t.qrToImageData(b.data,o,d),i(H,y,A),H.putImageData(b,0,0),y},e.renderToDataURL=function(o,u,c){let d=c;typeof d>"u"&&(!u||!u.getContext)&&(d=u,u=void 0),d||(d={});const y=e.render(o,u,d),A=d.type||"image/png",H=d.rendererOpts||{};return y.toDataURL(A,H.quality)}})(Kt);var Xt={};const io=ut;function Ft(e,t){const i=e.a/255,s=t+'="'+e.hex+'"';return i<1?s+" "+t+'-opacity="'+i.toFixed(2).slice(1)+'"':s}function et(e,t,i){let s=e+t;return typeof i<"u"&&(s+=" "+i),s}function lo(e,t,i){let s="",n=0,o=!1,u=0;for(let c=0;c<e.length;c++){const d=Math.floor(c%t),y=Math.floor(c/t);!d&&!o&&(o=!0),e[c]?(u++,c>0&&d>0&&e[c-1]||(s+=o?et("M",d+i,.5+y+i):et("m",n,0),n=0,o=!1),d+1<t&&e[c+1]||(s+=et("h",u),u=0)):n++}return s}Xt.render=function(t,i,s){const n=io.getOptions(i),o=t.modules.size,u=t.modules.data,c=o+n.margin*2,d=n.color.light.a?"<path "+Ft(n.color.light,"fill")+' d="M0 0h'+c+"v"+c+'H0z"/>':"",y="<path "+Ft(n.color.dark,"stroke")+' d="'+lo(u,o,n.margin)+'"/>',A='viewBox="0 0 '+c+" "+c+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(n.width?'width="'+n.width+'" height="'+n.width+'" ':"")+A+' shape-rendering="crispEdges">'+d+y+`</svg>
|
||
`;return typeof s=="function"&&s(null,b),b};const co=Ea,st=Bt,Zt=Kt,uo=Xt;function dt(e,t,i,s,n){const o=[].slice.call(arguments,1),u=o.length,c=typeof o[u-1]=="function";if(!c&&!co())throw new Error("Callback required as last argument");if(c){if(u<2)throw new Error("Too few arguments provided");u===2?(n=i,i=t,t=s=void 0):u===3&&(t.getContext&&typeof n>"u"?(n=s,s=void 0):(n=s,s=i,i=t,t=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(i=t,t=s=void 0):u===2&&!t.getContext&&(s=i,i=t,t=void 0),new Promise(function(d,y){try{const A=st.create(i,s);d(e(A,t,s))}catch(A){y(A)}})}try{const d=st.create(i,s);n(null,e(d,t,s))}catch(d){n(d)}}Me.create=st.create;Me.toCanvas=dt.bind(null,Zt.render);Me.toDataURL=dt.bind(null,Zt.renderToDataURL);Me.toString=dt.bind(null,function(e,t,i){return uo.render(e,i)});function mo(){const e=D(""),t=D(!1),i=D(null);return{qrCode:e,generating:t,error:i,generateQRCode:async c=>{if(!(c!=null&&c.name)&&!(c!=null&&c.assetNumber))throw new Error("Asset must have a name or asset number to generate QR code");t.value=!0,i.value=null;try{const d={id:c.assetNumber||`ASSET-${Date.now()}`,name:c.name||"Unnamed Asset",category:c.category||"Unspecified",location:c.location||"No location",status:c.status||"Unknown",criticality:c.criticality||"Not set",purchaseDate:c.purchaseDate||null,value:c.currentValue||c.purchasePrice||null,vendor:c.vendor||null,lastMaintenance:c.lastMaintenance||null,nextMaintenance:c.nextMaintenance||null,generatedAt:new Date().toISOString(),system:"Atlas CMMS",url:`${window.location.origin}/assets/${c.assetNumber||"new"}`},y=JSON.stringify(d),A=await Me.toDataURL(y,{width:300,margin:2,color:{dark:"#000000",light:"#FFFFFF"},errorCorrectionLevel:"H"});e.value=A;const H={qrCode:A,data:d};return console.log("✅ QR Code generated with data:",d),H}catch(d){throw i.value=d.message,console.error("❌ Failed to generate QR code:",d),d}finally{t.value=!1}},clearQRCode:()=>{e.value="",i.value=null},canGenerateQRCode:c=>!!(c!=null&&c.name||c!=null&&c.assetNumber),generatePrintContent:(c,d)=>{const y=c.name||"Asset",A=c.assetNumber||"TBD",H=c.location||"No Location",b=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Asset QR Label - ${y}</title>
|
||
<style>
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
margin: 0;
|
||
padding: 20px;
|
||
text-align: center;
|
||
}
|
||
.label {
|
||
border: 2px solid #000;
|
||
padding: 10px;
|
||
display: inline-block;
|
||
page-break-inside: avoid;
|
||
}
|
||
img {
|
||
width: 128px;
|
||
height: 128px;
|
||
margin-bottom: 8px;
|
||
}
|
||
.asset-info {
|
||
font-size: 10px;
|
||
line-height: 1.2;
|
||
}
|
||
.asset-name {
|
||
font-weight: bold;
|
||
font-size: 12px;
|
||
margin-bottom: 4px;
|
||
}
|
||
@media print {
|
||
body { margin: 0; padding: 10px; }
|
||
.label { page-break-inside: avoid; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="label">
|
||
<div>
|
||
<img src="${d}" alt="Asset QR Code" />
|
||
</div>
|
||
<div class="asset-info">
|
||
<div class="asset-name">${y}</div>
|
||
<div>ID: ${A}</div>
|
||
<div>${H}</div>
|
||
<div>${b}</div>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`}}}const fo={class:"asset-qr-generator"},go={class:"flex items-center justify-between mb-4"},vo={class:"flex space-x-2"},po={key:0,class:"mb-4 p-4 bg-red-50 border border-red-200 rounded-lg"},ho={class:"text-sm text-red-600"},yo={class:"bg-white p-6 rounded-lg border-2 border-gray-200 text-center"},wo={key:0,class:"py-8"},Co={key:1,class:"space-y-4"},Ao={class:"flex justify-center"},bo=["src"],Io={class:"text-left bg-gray-50 p-4 rounded border"},Eo={class:"grid grid-cols-2 gap-2 text-sm"},Mo={key:2,class:"py-8 text-gray-500"},So={class:"flex min-h-full items-center justify-center p-4"},No={class:"p-6"},ko={id:"qr-print-content",class:"border p-4 bg-white text-center"},To={class:"mb-3"},xo=["src"],_o={class:"text-xs space-y-1"},Ro={class:"font-bold"},Do={class:"mt-4 flex justify-end space-x-3"},Po={__name:"AssetQRGenerator",props:{assetData:{type:Object,required:!0},autoGenerate:{type:Boolean,default:!0}},emits:["qr-generated"],setup(e,{emit:t}){const i=e,s=t,{qrCode:n,generating:o,error:u,generateQRCode:c,canGenerateQRCode:d,generatePrintContent:y}=mo(),A=D(!1),H=async()=>{if(d(i.assetData))try{const N=await c(i.assetData);s("qr-generated",N)}catch(N){console.error("QR generation failed:",N.message)}},b=()=>{H()},P=()=>{A.value=!0},V=()=>{A.value=!1},z=()=>{const N=y(i.assetData,n.value),w=window.open("","_blank");w.document.write(N),w.document.close(),w.print(),w.close(),V()},Y=N=>N?new Date(N).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Not set";return i.autoGenerate&&Fn(()=>{H()}),(N,w)=>(k(),R("div",fo,[r("div",go,[w[3]||(w[3]=r("div",null,[r("h4",{class:"text-lg font-medium text-gray-900"},"Asset QR Code"),r("p",{class:"text-sm text-gray-600"},"Automatically generated QR code with asset details")],-1)),r("div",vo,[x(C(J),{variant:"outline",size:"sm",onClick:b,loading:C(o)},{default:B(()=>w[1]||(w[1]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1),q(" Regenerate ",-1)])),_:1,__:[1]},8,["loading"]),x(C(J),{variant:"primary",size:"sm",onClick:P,disabled:!C(n)},{default:B(()=>w[2]||(w[2]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H9.414a1 1 0 01-.707-.293l-1.414-1.414A1 1 0 006.586 7H4a2 2 0 00-2 2v6a2 2 0 002 2h2m5 5v-5a1.5 1.5 0 011.5-1.5h9A1.5 1.5 0 0122 15.5v5a1.5 1.5 0 01-1.5 1.5h-9A1.5 1.5 0 0111 20.5z"})],-1),q(" Print QR Label ",-1)])),_:1,__:[2]},8,["disabled"])])]),C(u)?(k(),R("div",po,[r("p",ho,$(C(u)),1)])):W("",!0),r("div",yo,[C(o)?(k(),R("div",wo,w[4]||(w[4]=[r("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600 mx-auto"},null,-1),r("p",{class:"text-sm text-gray-600 mt-2"},"Generating QR code...",-1)]))):C(n)?(k(),R("div",Co,[r("div",Ao,[r("img",{src:C(n),alt:"Asset QR Code",class:"max-w-xs"},null,8,bo)]),r("div",Io,[w[13]||(w[13]=r("h5",{class:"font-medium text-gray-900 mb-2"},"QR Code Contains:",-1)),r("div",Eo,[r("div",null,[w[5]||(w[5]=r("strong",null,"Asset ID:",-1)),q(" "+$(e.assetData.assetNumber||"Auto-generated"),1)]),r("div",null,[w[6]||(w[6]=r("strong",null,"Name:",-1)),q(" "+$(e.assetData.name||"Unnamed Asset"),1)]),r("div",null,[w[7]||(w[7]=r("strong",null,"Category:",-1)),q(" "+$(e.assetData.category||"Unspecified"),1)]),r("div",null,[w[8]||(w[8]=r("strong",null,"Location:",-1)),q(" "+$(e.assetData.location||"No location"),1)]),r("div",null,[w[9]||(w[9]=r("strong",null,"Status:",-1)),q(" "+$(e.assetData.status||"Unknown"),1)]),r("div",null,[w[10]||(w[10]=r("strong",null,"Criticality:",-1)),q(" "+$(e.assetData.criticality||"Not set"),1)]),r("div",null,[w[11]||(w[11]=r("strong",null,"Last Maintenance:",-1)),q(" "+$(Y(e.assetData.lastMaintenance)),1)]),r("div",null,[w[12]||(w[12]=r("strong",null,"Next Maintenance:",-1)),q(" "+$(Y(e.assetData.nextMaintenance)),1)])])])])):(k(),R("div",Mo,w[14]||(w[14]=[r("svg",{class:"w-16 h-16 mx-auto mb-2 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1",d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 16h4m-4 0v4m-4-4h4"})],-1),r("p",null,"QR code will be generated automatically",-1)])))]),A.value?(k(),R("div",{key:1,class:"fixed inset-0 z-50 overflow-y-auto",onClick:V},[r("div",So,[w[19]||(w[19]=r("div",{class:"fixed inset-0 bg-black bg-opacity-50"},null,-1)),r("div",{class:"relative bg-white rounded-lg shadow-xl max-w-md w-full",onClick:w[0]||(w[0]=De(()=>{},["stop"]))},[r("div",No,[r("div",{class:"flex items-center justify-between mb-4"},[w[16]||(w[16]=r("h3",{class:"text-lg font-medium text-gray-900"},"Print QR Label",-1)),r("button",{onClick:V,class:"text-gray-400 hover:text-gray-600"},w[15]||(w[15]=[r("svg",{class:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),r("div",ko,[r("div",To,[r("img",{src:C(n),alt:"Asset QR Code",class:"w-32 h-32 mx-auto"},null,8,xo)]),r("div",_o,[r("div",Ro,$(e.assetData.name||"Asset"),1),r("div",null,"ID: "+$(e.assetData.assetNumber||"TBD"),1),r("div",null,$(e.assetData.location||"No Location"),1),r("div",null,$(Y(new Date)),1)])]),r("div",Do,[x(C(J),{variant:"secondary",onClick:V},{default:B(()=>w[17]||(w[17]=[q("Cancel",-1)])),_:1,__:[17]}),x(C(J),{variant:"primary",onClick:z},{default:B(()=>w[18]||(w[18]=[q("Print Label",-1)])),_:1,__:[18]})])])])])])):W("",!0)]))}},Oo=rt(Po,[["__scopeId","data-v-f7f02383"]]),Lo={key:0},Fo={key:0},Bo={class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Vo={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 10h16M4 14h16M4 18h16"},Uo={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"},zo={key:0},Ho={key:1},$o={class:"p-6"},jo={key:0,class:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-center"},Yo={class:"text-yellow-800"},Go={class:"flex items-center"},qo={class:"font-medium text-gray-900"},Qo={class:"text-sm text-gray-600"},Wo={class:"flex items-center"},Jo={class:"w-12 h-2 bg-gray-200 rounded-full mr-2"},Ko={key:0,class:"w-3 h-3 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Xo={key:1,class:"w-3 h-3 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Zo={key:2,class:"w-3 h-3 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},es={key:0,class:"text-sm text-gray-900"},ts={key:1,class:"text-sm text-gray-400"},ns={key:1,class:"text-sm text-gray-400"},as={class:"text-sm font-medium text-gray-900"},os={class:"flex items-center space-x-2"},ss={key:0},rs={key:0},is={key:0},ls={key:0},cs={key:2,class:"space-y-4"},us={key:0,class:"flex items-center justify-center py-12"},ds={key:1,class:"text-center py-12"},ms={key:2},fs=["onClick"],gs={class:"flex items-start justify-between mb-3"},vs={class:"flex items-center flex-1 min-w-0"},ps={class:"flex-1 min-w-0"},hs={class:"text-lg font-medium text-gray-900 truncate"},ys={class:"text-sm text-gray-600 truncate"},ws={class:"flex flex-col items-end space-y-2 ml-4"},Cs={class:"mb-3"},As={class:"flex items-center justify-between mb-1"},bs={class:"w-full h-2 bg-gray-200 rounded-full"},Is={class:"grid grid-cols-2 gap-4 text-sm"},Es={class:"font-medium text-gray-900 mt-1"},Ms={class:"mt-1"},Ss={key:0,class:"text-gray-900"},Ns={key:1,class:"text-gray-400"},ks={class:"mt-1"},Ts={key:1,class:"text-gray-400"},xs={class:"mt-1"},_s={class:"flex items-center justify-between mt-4 pt-3 border-t border-gray-100"},Rs={class:"text-sm text-gray-500"},Ds={class:"flex space-x-2"},Ps={key:0,class:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg"},Os={class:"flex items-center justify-between"},Ls={class:"text-sm text-blue-700 mt-1"},Fs={class:"flex space-x-2"},Bs={class:"border-b border-gray-200 mb-6"},Vs={key:1,class:"space-y-6"},Us={class:"col-span-full"},zs={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},Hs={key:0,class:"mt-1 text-sm text-red-600"},$s={key:2,class:"space-y-4"},js={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Ys={key:3,class:"space-y-4"},Gs={key:4,class:"space-y-4"},qs={key:5,class:"space-y-6"},Qs={class:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-gray-400 transition-colors"},Ws={class:"mt-4"},Js={class:"cursor-pointer"},Ks={key:0,class:"mt-4 space-y-2"},Xs={class:"flex items-center"},Zs={class:"text-sm font-medium text-gray-900"},er={class:"text-xs text-gray-500"},tr={class:"mt-2 text-xs text-gray-500"},nr={class:"mt-2"},ar={key:6,class:"space-y-4"},or={class:"flex items-center justify-between"},sr={class:"flex items-center space-x-4"},rr={key:0,class:"flex items-center text-sm text-gray-500"},ir={key:0,class:"w-4 h-4 mr-2 text-amber-500 animate-pulse",fill:"currentColor",viewBox:"0 0 20 20"},lr={key:1,class:"w-4 h-4 mr-2 text-green-500",fill:"currentColor",viewBox:"0 0 20 20"},cr={key:2},ur={key:3},dr={class:"flex space-x-3"},mr={key:0,class:"space-y-6"},fr={class:"bg-gray-50 rounded-lg p-4"},gr={class:"grid grid-cols-2 md:grid-cols-4 gap-4"},vr={class:"text-center"},pr={class:"text-center"},hr={class:"text-2xl font-bold text-blue-600"},yr={class:"text-center"},wr={class:"text-2xl font-bold text-green-600"},Cr={class:"text-center"},Ar={key:0},br={class:"space-y-2"},Ir={class:"text-blue-800"},ve="atlas_asset_form_data",Er={__name:"AssetsListView",setup(e){const t=Vn(),i=Bn(),s=$n(),n=Qn(),{calculateHealthScore:o,assessRisk:u}=sa(),{analyzePerformance:c}=oa(),{loadAssetHierarchy:d}=Wn(),{isOnline:y,syncStatus:A,syncPendingActions:H}=ra(),{isMobile:b,layoutClass:P,optimizeTableForMobile:V}=Xn(),{complianceScore:z,activeViolations:Y,upcomingRenewals:N}=ia(),w=D(!1),T=D(!1),_=D(!1),F=D(null),M=D("all"),S=D(!1),E=D("create"),G=D(null),v=D("basic"),l=D(!1),m=D({}),g=D(!1),O=D(null),U=D(!1),j=D(null),K=D(!1),re=D(!1),L=D(0),h=D({name:"",assetNumber:"",description:"",category:"",status:"",criticality:"",location:"",purchasePrice:0,currentValue:0,purchaseDate:null,installationDate:null,vendor:"",model:"",lastMaintenance:null,nextMaintenance:null,warranty:{isWarrantyActive:!1,warrantyStartDate:null,warrantyEndDate:null,warrantyProvider:"",status:"NOT_APPLICABLE"},customFields:{},image:null,files:[],qrCode:null,qrData:null}),Q=D({search:"",status:"",category:"",location:"",criticality:""}),Z=D(new Map),ie=D({currentPage:1,pageSize:10,total:0}),ee=X(()=>s.assets),Ne=X(()=>s.loading),en=X(()=>[{key:"all",label:"All Assets",badge:ee.value.length},{key:"operational",label:"Operational",badge:ee.value.filter(f=>f.status===me.OPERATIONAL).length},{key:"maintenance",label:"Maintenance",badge:ee.value.filter(f=>f.status===me.MAINTENANCE).length},{key:"down",label:"Down",badge:ee.value.filter(f=>f.status===me.DOWN).length},{key:"critical_violations",label:"Compliance Issues",badge:Y.value.length}]),tn=X(()=>V([{key:"name",label:"Asset",sortable:!0,essential:!0,priority:"high"},{key:"status",label:"Status",sortable:!0,essential:!0,priority:"high"},{key:"healthScore",label:"Health",sortable:!0,priority:"high"},{key:"location",label:"Location",sortable:!0,priority:"medium"},{key:"criticality",label:"Criticality",sortable:!0,priority:"high"},{key:"lastMaintenance",label:"Last Maintenance",sortable:!0,priority:"medium"},{key:"nextMaintenance",label:"Next Maintenance",sortable:!0,priority:"medium"},{key:"complianceStatus",label:"Compliance",sortable:!0,priority:"low"},{key:"value",label:"Value",sortable:!0,priority:"low"}])),mt=X(()=>Object.entries(jn).map(([f,a])=>({title:a.label,value:f}))),nn=X(()=>(n.locations.value||{content:[]}).content.map(a=>({title:a.name,value:a.id}))),ft=X(()=>Object.entries(Yn).map(([f,a])=>({title:a.label,value:f}))),an=X(()=>{const f=ee.value.length,a=ee.value.filter(I=>I.status===me.OPERATIONAL).length;ee.value.filter(I=>I.criticality===Gn.CRITICAL).length,ee.value.reduce((I,te)=>I+(te.value||0),0);const p=f>0?Math.round(ee.value.reduce((I,te)=>I+o(te),0)/f):0;return[{name:"Total Assets",value:f,subtitle:y.value?"Live data":"Offline mode",icon:"building",iconBg:"bg-blue-100",iconColor:"text-blue-600",change:8},{name:"Operational",value:a,subtitle:`${f>0?Math.round(a/f*100):0}% uptime`,icon:"check-circle",iconBg:"bg-green-100",iconColor:"text-green-600",change:5},{name:"Health Score",value:`${p}%`,subtitle:"Average asset health",icon:"heart",iconBg:p>=80?"bg-green-100":p>=60?"bg-yellow-100":"bg-red-100",iconColor:p>=80?"text-green-600":p>=60?"text-yellow-600":"text-red-600",change:3},{name:"Compliance",value:`${z.value}%`,subtitle:Y.value.length>0?`${Y.value.length} violations`:"All compliant",icon:"shield-check",iconBg:z.value>=90?"bg-green-100":z.value>=70?"bg-yellow-100":"bg-red-100",iconColor:z.value>=90?"text-green-600":z.value>=70?"text-yellow-600":"text-red-600",change:-2}]}),Ue=X(()=>{let f=ee.value;if(M.value!=="all"){const a={operational:me.OPERATIONAL,maintenance:me.MAINTENANCE,down:me.DOWN,critical_violations:null};if(M.value==="critical_violations"){const p=Y.value.map(I=>I.assetId);f=f.filter(I=>p.includes(I.id))}else f=f.filter(p=>p.status===a[M.value])}if(Q.value.search){const a=Q.value.search.toLowerCase();f=f.filter(p=>{var I,te,fe,xt;return p.name.toLowerCase().includes(a)||((I=p.model)==null?void 0:I.toLowerCase().includes(a))||((te=p.location)==null?void 0:te.toLowerCase().includes(a))||((fe=p.serialNumber)==null?void 0:fe.toLowerCase().includes(a))||((xt=p.assetNumber)==null?void 0:xt.toLowerCase().includes(a))})}return Q.value.category&&(f=f.filter(a=>a.category===Q.value.category)),Q.value.location&&(f=f.filter(a=>a.location===Q.value.location)),Q.value.criticality&&(f=f.filter(a=>a.criticality===Q.value.criticality)),f.map(a=>({...a,healthScore:o(a),riskLevel:u(a),complianceStatus:vn(a.id)}))}),on=X(()=>{const f=E.value==="create"?"Create New Asset":"Edit Asset";return U.value?`${f} (Unsaved Changes)`:f}),sn=X(()=>{if(!j.value)return"";const f=new Date,a=new Date(j.value),p=f-a,I=Math.floor(p/(60*1e3));return I<1?"just now":I===1?"1 minute ago":I<60?`${I} minutes ago`:a.toLocaleTimeString()}),Ce=[{key:"basic",label:"Basic Information"},{key:"financial",label:"Financial Information"},{key:"warranty",label:"Warranty"},{key:"custom",label:"Custom Fields"},{key:"attachments",label:"Attachments"},{key:"qr",label:"QR Code"}],rn=X(()=>Object.entries(qn).map(([f,a])=>({title:a.label,value:f}))),ze=async()=>{w.value=!0;try{await Promise.all([s.loadAssets(),n.refreshLocations(),d(),H()])}catch(f){console.error("Failed to refresh data:",f)}finally{w.value=!1}},ln=()=>{console.log("Exporting assets...")},cn=()=>{_.value=!_.value},un=f=>{ke(f.id)},dn=()=>{E.value="create",G.value=null,v.value="basic",On(),qe()||(Ye(),Tt()),S.value=!0},He=f=>{const a=ee.value.find(p=>p.id===f);a&&(E.value="edit",G.value=f,v.value="basic",Object.assign(h.value,a),setTimeout(()=>{K.value=!1},100),S.value=!0)},ke=f=>{t.push(`/assets/${f}`)},gt=f=>{t.push(`/work-orders?create=true&assetId=${f}`)},mn=async f=>{try{if(w.value=!0,Z.value.has(f))F.value=Z.value.get(f);else{const a=ee.value.find(te=>te.id===f),I={...await c(f,[]),healthScore:o(a),riskLevel:u(a),recommendations:["Schedule preventive maintenance within 2 weeks","Monitor temperature sensors more frequently","Consider component replacement for optimal performance","Update maintenance procedures based on usage patterns"]};Z.value.set(f,I),F.value=I}T.value=!0}catch(a){console.error("Failed to analyze asset:",a)}finally{w.value=!1}},fn=()=>{T.value=!1,F.value=null},gn=()=>{console.log("Generating detailed report for asset:",F.value)},vn=f=>{const a=Y.value.filter(I=>I.assetId===f),p=N.value.filter(I=>I.assetId===f);return a.length>0?"NON_COMPLIANT":p.length>0?"EXPIRING_SOON":"COMPLIANT"},pn=f=>{M.value=f},hn=()=>{},$e=()=>{},yn=({column:f,direction:a})=>{console.log("Sort:",f,a)},wn=f=>{ie.value.currentPage=f},Cn=({row:f})=>{ke(f.id)},vt=f=>({OPERATIONAL:"success",MAINTENANCE:"warning",DOWN:"error",DECOMMISSIONED:"secondary"})[f]||"default",pt=f=>({LOW:"secondary",MEDIUM:"info",HIGH:"warning",CRITICAL:"error"})[f]||"default",ht=f=>f.toLowerCase().replace(/\b\w/g,a=>a.toUpperCase()),yt=f=>f.toLowerCase().replace(/\b\w/g,a=>a.toUpperCase()),Te=f=>new Date(f).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),wt=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0}).format(f),Ct=f=>{const a=new Date(f),I=Math.ceil((a-new Date)/(1e3*60*60*24));return I<0?"text-red-600":I<=7?"text-orange-600":"text-gray-900"},At=f=>f>=80?"bg-green-500":f>=60?"bg-yellow-500":"bg-red-500",je=f=>f>=80?"text-green-600":f>=60?"text-yellow-600":"text-red-600",bt=f=>({COMPLIANT:"success",NON_COMPLIANT:"error",EXPIRING_SOON:"warning"})[f]||"secondary",It=f=>({COMPLIANT:"Compliant",NON_COMPLIANT:"Issues",EXPIRING_SOON:"Expiring"})[f]||f,An=f=>f==="HIGH"?"text-red-600":f==="MEDIUM"?"text-yellow-600":"text-green-600",Ye=()=>{h.value={name:"",assetNumber:"",description:"",category:"",status:"OPERATIONAL",criticality:"MEDIUM",location:"",purchasePrice:0,currentValue:0,purchaseDate:null,installationDate:null,vendor:"",model:"",warranty:{isWarrantyActive:!1,warrantyStartDate:null,warrantyEndDate:null,warrantyProvider:"",status:"NOT_APPLICABLE"},customFields:{}},m.value={},K.value=!1,U.value=!1},Et=f=>{const a=Ce.findIndex(p=>p.key===v.value);f==="next"&&a<Ce.length-1?v.value=Ce[a+1].key:f==="previous"&&a>0&&(v.value=Ce[a-1].key)},bn=async f=>{console.log("Primary image uploaded:",f)},In=async f=>{console.log("Additional files uploaded:",f)},En=f=>{const a=Array.from(f.target.files);if(!a.length)return;const p=a.map(I=>({...I,id:Date.now()+Math.random(),uploadedAt:new Date().toISOString(),uploadedBy:null}));h.files||(h.files=[]),h.files.push(...p),f.target.value=""},Mn=f=>{h.files&&h.files[f]&&h.files.splice(f,1)},Sn=f=>{if(!f)return"0 B";const a=["B","KB","MB","GB"],p=Math.floor(Math.log(f)/Math.log(1024));return`${Math.round(f/Math.pow(1024,p)*100)/100} ${a[p]}`},Nn=f=>{if(!f)return"just now";const a=new Date(f),I=new Date-a,te=Math.floor(I/(1e3*60));if(te<1)return"just now";if(te<60)return`${te}m ago`;const fe=Math.floor(te/60);return fe<24?`${fe}h ago`:a.toLocaleDateString()},kn=f=>{v.value=f,le()},Tn=()=>{var f;return m.value={},(f=h.value.name)!=null&&f.trim()||(m.value.name="Asset name is required"),h.value.category||(m.value.category="Category is required"),h.value.status||(m.value.status="Status is required"),h.value.criticality||(m.value.criticality="Criticality is required"),Object.keys(m.value).length===0},xn=f=>{console.log("Warranty validation:",f)},_n=f=>{console.log("Custom fields validation:",f)},Rn=f=>{h.value.qrCode=f.qrCode,h.value.qrData=f.data,console.log("✅ QR Code generated and stored:",f)},Ge=()=>{xe(),S.value=!1,Ye(),g.value=!1},Mt=async()=>{if(Tn())try{l.value=!0,E.value==="create"?await s.createAsset(h.value):await s.updateAsset(G.value,h.value),xe(),Ge(),await ze()}catch(f){console.error("Failed to save asset:",f)}finally{l.value=!1}};tt(()=>{const{qrCode:f,qrData:a,...p}=h.value;return p},()=>{K.value&&le()},{deep:!0}),Ee(async()=>{await ze(),b.value&&(_.value=!0);const f=i.query.edit;f&&setTimeout(()=>{He(parseInt(f)),t.replace({path:"/assets"})},500);try{await Promise.all([...ee.value.map(a=>Promise.resolve())])}catch(a){console.error("Failed to load compliance data:",a)}});const qe=()=>{try{return localStorage.getItem(ve)!==null}catch{return!1}},St=()=>{try{const f=localStorage.getItem(ve);if(!f)return null;const a=JSON.parse(f);return{timestamp:a.timestamp,formData:a.formData}}catch{return null}},Dn=()=>{if(console.log("💾 saveAssetFormData called, userInteracted:",K.value),!K.value){console.log("❌ Not saving - user has not interacted");return}try{const f={timestamp:new Date().toISOString(),formData:{...h.value}};delete f.formData.image,delete f.formData.files,console.log("📝 Saving to localStorage:",ve,f),localStorage.setItem(ve,JSON.stringify(f)),j.value=f.timestamp,U.value=!1,console.log("✅ Asset form auto-saved successfully at",f.timestamp)}catch(f){console.warn("❌ Failed to save asset form:",f)}},Pn=()=>{try{const f=localStorage.getItem(ve);if(!f)return!1;const a=JSON.parse(f);return Object.assign(h.value,a.formData),j.value=a.timestamp,console.log("Asset form data restored"),!0}catch(f){return console.warn("Failed to restore asset form:",f),!1}},xe=()=>{try{localStorage.removeItem(ve),j.value=null,U.value=!1,console.log("Asset saved data cleared")}catch(f){console.warn("Failed to clear asset saved data:",f)}},le=()=>{console.log("🔥 User interaction detected!"),K.value=!0,U.value=!0,setTimeout(()=>{U.value&&K.value&&(console.log("💾 Triggering auto-save..."),Dn())},3e3)},On=()=>{console.log("=== Checking for asset saved data ==="),console.log("Modal mode:",E.value),console.log("Has saved data:",qe()),console.log("Saved data info:",St()),E.value==="create"&&qe()?(O.value=St(),g.value=!0,console.log("✅ Found saved asset data, showing restore notification"),console.log("Notification visible:",g.value)):console.log("❌ No saved data or not in create mode")},Nt=()=>{Pn()&&(g.value=!1,console.log("Asset form data restored successfully"))},kt=()=>{g.value=!1,xe(),Ye(),Tt(),console.log("Asset auto-saved data dismissed")},Tt=()=>{h.value.status||(h.value.status="OPERATIONAL"),h.value.files||(h.value.files=[]),h.value.customFields||(h.value.customFields={})};return Un(()=>{xe()}),(f,a)=>(k(),Ae(Zn,null,{header:B(()=>[x(ea,{title:"Assets",description:"Manage and track all facility assets and equipment",breadcrumbs:[{text:"Assets",to:null}]},{actions:B(()=>[x(C(J),{variant:"outline",size:"sm",onClick:ln},{default:B(()=>[(k(),R("svg",{class:ne(["w-4 h-4",C(b)?"":"mr-2"]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},a[27]||(a[27]=[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"},null,-1)]),2)),C(b)?W("",!0):(k(),R("span",Lo,"Export"))]),_:1}),x(C(J),{variant:"outline",size:"sm",onClick:ze},{default:B(()=>[(k(),R("svg",{class:ne(["w-4 h-4",C(b)?"":"mr-2"]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},a[28]||(a[28]=[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)]),2)),C(b)?W("",!0):(k(),R("span",Fo,"Refresh"))]),_:1}),C(b)?(k(),Ae(C(J),{key:0,variant:"outline",size:"sm",onClick:cn},{default:B(()=>[(k(),R("svg",Bo,[_.value?(k(),R("path",Vo)):(k(),R("path",Uo))]))]),_:1})):W("",!0),x(C(J),{variant:"primary",size:"sm",onClick:dn},{default:B(()=>[(k(),R("svg",{class:ne(["w-4 h-4",C(b)?"":"mr-2"]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},a[29]||(a[29]=[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"},null,-1)]),2)),C(b)?(k(),R("span",Ho,"Add")):(k(),R("span",zo,"Add Asset"))]),_:1})]),stats:B(()=>[x(C(ta),{stats:an.value},null,8,["stats"])]),tabs:B(()=>[x(C(Dt),{modelValue:M.value,"onUpdate:modelValue":a[0]||(a[0]=p=>M.value=p),tabs:en.value,onTabChange:pn},null,8,["modelValue","tabs"])]),_:1})]),default:B(()=>[r("div",$o,[r("div",{class:ne(["mb-6 grid gap-4",C(b)?"grid-cols-1":"grid-cols-1 md:grid-cols-4"])},[x(C(oe),{modelValue:Q.value.search,"onUpdate:modelValue":a[1]||(a[1]=p=>Q.value.search=p),placeholder:"Search assets...",onInput:hn},{prepend:B(()=>a[30]||(a[30]=[r("svg",{class:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1)])),_:1},8,["modelValue"]),x(C(ce),{modelValue:Q.value.category,"onUpdate:modelValue":[a[2]||(a[2]=p=>Q.value.category=p),$e],placeholder:"Filter by Category",options:mt.value},null,8,["modelValue","options"]),x(C(ce),{modelValue:Q.value.location,"onUpdate:modelValue":[a[3]||(a[3]=p=>Q.value.location=p),$e],placeholder:"Filter by Location",options:nn.value},null,8,["modelValue","options"]),x(C(ce),{modelValue:Q.value.criticality,"onUpdate:modelValue":[a[4]||(a[4]=p=>Q.value.criticality=p),$e],placeholder:"Filter by Criticality",options:ft.value},null,8,["modelValue","options"])],2),C(y)?W("",!0):(k(),R("div",jo,[a[31]||(a[31]=r("svg",{class:"w-5 h-5 text-yellow-600 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L4.316 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),r("span",Yo,"Working offline - "+$(C(A))+" mode active",1)])),!C(b)||!_.value?(k(),R("div",{key:1,class:ne(C(P))},[x(C(na),{columns:tn.value,data:Ue.value,loading:Ne.value,pagination:ie.value,"empty-message":"No assets found",onSortChange:yn,onPageChange:wn,onRowClick:Cn},{"column-name":B(({row:p})=>[r("div",Go,[a[32]||(a[32]=r("div",{class:"w-10 h-10 rounded bg-primary-100 flex items-center justify-center mr-3"},[r("svg",{class:"w-5 h-5 text-primary-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})])],-1)),r("div",null,[r("h4",qo,$(p.name),1),r("p",Qo,$(p.model||"No model specified"),1)])])]),"column-status":B(({row:p})=>[x(C(ge),{variant:vt(p.status)},{default:B(()=>[q($(ht(p.status)),1)]),_:2},1032,["variant"])]),"column-healthScore":B(({row:p})=>[r("div",Wo,[r("div",Jo,[r("div",{class:ne(["h-2 rounded-full transition-all duration-300",At(p.healthScore)]),style:_t({width:`${p.healthScore}%`})},null,6)]),r("span",{class:ne(["text-sm font-medium",je(p.healthScore)])},$(p.healthScore)+"% ",3)])]),"column-criticality":B(({row:p})=>[x(C(ge),{variant:pt(p.criticality)},{default:B(()=>[q($(yt(p.criticality)),1)]),_:2},1032,["variant"])]),"column-complianceStatus":B(({row:p})=>[x(C(ge),{variant:bt(p.complianceStatus)},{default:B(()=>[p.complianceStatus==="NON_COMPLIANT"?(k(),R("svg",Ko,a[33]||(a[33]=[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L4.316 16.5c-.77.833.192 2.5 1.732 2.5z"},null,-1)]))):p.complianceStatus==="EXPIRING_SOON"?(k(),R("svg",Xo,a[34]||(a[34]=[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)]))):(k(),R("svg",Zo,a[35]||(a[35]=[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)]))),q(" "+$(It(p.complianceStatus)),1)]),_:2},1032,["variant"])]),"column-lastMaintenance":B(({row:p})=>[p.lastMaintenance?(k(),R("div",es,$(Te(p.lastMaintenance)),1)):(k(),R("span",ts,"Never"))]),"column-nextMaintenance":B(({row:p})=>[p.nextMaintenance?(k(),R("div",{key:0,class:ne(["text-sm",Ct(p.nextMaintenance)])},$(Te(p.nextMaintenance)),3)):(k(),R("span",ns,"Not scheduled"))]),"column-value":B(({row:p})=>[r("div",as,$(wt(p.value)),1)]),"row-actions":B(({row:p})=>[r("div",os,[x(C(J),{variant:"ghost",size:"sm",onClick:I=>ke(p.id),title:"View Details"},{default:B(()=>[a[36]||(a[36]=r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})],-1)),C(b)?W("",!0):(k(),R("span",ss,"View"))]),_:2,__:[36]},1032,["onClick"]),x(C(J),{variant:"ghost",size:"sm",onClick:I=>He(p.id),title:"Edit Asset"},{default:B(()=>[a[37]||(a[37]=r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)),C(b)?W("",!0):(k(),R("span",rs,"Edit"))]),_:2,__:[37]},1032,["onClick"]),x(C(J),{variant:"ghost",size:"sm",onClick:I=>gt(p.id),title:"Create Work Order"},{default:B(()=>[a[38]||(a[38]=r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})],-1)),C(b)?W("",!0):(k(),R("span",is,"Work Order"))]),_:2,__:[38]},1032,["onClick"]),p.riskLevel==="HIGH"?(k(),Ae(C(J),{key:0,variant:"ghost",size:"sm",onClick:I=>mn(p.id),title:"AI Analysis",class:"text-orange-600 hover:text-orange-700"},{default:B(()=>[a[39]||(a[39]=r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})],-1)),C(b)?W("",!0):(k(),R("span",ls,"Analyze"))]),_:2,__:[39]},1032,["onClick"])):W("",!0)])]),_:1},8,["columns","data","loading","pagination"])],2)):C(b)&&_.value?(k(),R("div",cs,[Ne.value?(k(),R("div",us,a[40]||(a[40]=[r("div",{class:"flex items-center space-x-2 text-gray-500"},[r("svg",{class:"w-6 h-6 animate-spin",fill:"none",viewBox:"0 0 24 24"},[r("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),r("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),r("span",null,"Loading assets...")],-1)]))):Ue.value.length===0?(k(),R("div",ds,a[41]||(a[41]=[r("div",{class:"text-gray-500"},[r("svg",{class:"w-12 h-12 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})]),r("p",{class:"text-lg font-medium"},"No assets found"),r("p",{class:"text-sm mt-1"},"Try adjusting your filters or create a new asset")],-1)]))):(k(),R("div",ms,[(k(!0),R(Qe,null,We(Ue.value,p=>(k(),R("div",{key:p.id,class:"bg-white rounded-lg shadow border border-gray-200 p-4 touch-manipulation",onClick:I=>un(p)},[r("div",gs,[r("div",vs,[a[42]||(a[42]=r("div",{class:"w-12 h-12 rounded bg-primary-100 flex items-center justify-center mr-3 flex-shrink-0"},[r("svg",{class:"w-6 h-6 text-primary-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})])],-1)),r("div",ps,[r("h3",hs,$(p.name),1),r("p",ys,$(p.model||"No model specified"),1)])]),r("div",ws,[x(C(ge),{variant:vt(p.status)},{default:B(()=>[q($(ht(p.status)),1)]),_:2},1032,["variant"]),x(C(ge),{variant:pt(p.criticality)},{default:B(()=>[q($(yt(p.criticality)),1)]),_:2},1032,["variant"])])]),r("div",Cs,[r("div",As,[a[43]||(a[43]=r("span",{class:"text-sm text-gray-500"},"Health Score",-1)),r("span",{class:ne(["text-sm font-medium",je(p.healthScore)])},$(p.healthScore)+"% ",3)]),r("div",bs,[r("div",{class:ne(["h-2 rounded-full transition-all duration-300",At(p.healthScore)]),style:_t({width:`${p.healthScore}%`})},null,6)])]),r("div",Is,[r("div",null,[a[44]||(a[44]=r("span",{class:"text-gray-500"},"Value:",-1)),r("div",Es,$(wt(p.value)),1)]),r("div",null,[a[45]||(a[45]=r("span",{class:"text-gray-500"},"Last Maintenance:",-1)),r("div",Ms,[p.lastMaintenance?(k(),R("span",Ss,$(Te(p.lastMaintenance)),1)):(k(),R("span",Ns,"Never"))])]),r("div",null,[a[46]||(a[46]=r("span",{class:"text-gray-500"},"Next Maintenance:",-1)),r("div",ks,[p.nextMaintenance?(k(),R("span",{key:0,class:ne(Ct(p.nextMaintenance))},$(Te(p.nextMaintenance)),3)):(k(),R("span",Ts,"Not scheduled"))])]),r("div",null,[a[47]||(a[47]=r("span",{class:"text-gray-500"},"Compliance:",-1)),r("div",xs,[x(C(ge),{variant:bt(p.complianceStatus),size:"xs"},{default:B(()=>[q($(It(p.complianceStatus)),1)]),_:2},1032,["variant"])])])]),r("div",_s,[r("div",Rs," ID: "+$(p.id),1),r("div",Ds,[x(C(J),{variant:"ghost",size:"xs",onClick:De(I=>He(p.id),["stop"])},{default:B(()=>a[48]||(a[48]=[q(" Edit ",-1)])),_:2,__:[48]},1032,["onClick"]),x(C(J),{variant:"ghost",size:"xs",onClick:De(I=>ke(p.id),["stop"])},{default:B(()=>a[49]||(a[49]=[q(" View ",-1)])),_:2,__:[49]},1032,["onClick"]),x(C(J),{variant:"ghost",size:"xs",onClick:De(I=>gt(p.id),["stop"])},{default:B(()=>a[50]||(a[50]=[q(" WO ",-1)])),_:2,__:[50]},1032,["onClick"])])])],8,fs))),128))]))])):W("",!0)]),x(C(Rt),{modelValue:S.value,"onUpdate:modelValue":a[25]||(a[25]=p=>S.value=p),title:on.value,size:C(b)?"full":"xl",onConfirm:Mt,onCancel:Ge},{footer:B(()=>[r("div",or,[r("div",sr,[U.value||j.value?(k(),R("div",rr,[U.value?(k(),R("svg",ir,a[65]||(a[65]=[r("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z","clip-rule":"evenodd"},null,-1)]))):(k(),R("svg",lr,a[66]||(a[66]=[r("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1)]))),U.value?(k(),R("span",cr,"Auto-saving...")):j.value?(k(),R("span",ur,"Last saved "+$(sn.value),1)):W("",!0)])):W("",!0),v.value!=="basic"?(k(),Ae(C(J),{key:1,variant:"outline",size:"sm",onClick:a[23]||(a[23]=p=>Et("previous"))},{default:B(()=>a[67]||(a[67]=[q(" ← Previous ",-1)])),_:1,__:[67]})):W("",!0)]),r("div",dr,[x(C(J),{variant:"secondary",onClick:Ge},{default:B(()=>a[68]||(a[68]=[q(" Cancel ",-1)])),_:1,__:[68]}),v.value!=="qr"?(k(),Ae(C(J),{key:0,variant:"outline",onClick:a[24]||(a[24]=p=>Et("next"))},{default:B(()=>a[69]||(a[69]=[q(" Next → ",-1)])),_:1,__:[69]})):W("",!0),x(C(J),{variant:"primary",loading:l.value,onClick:Mt},{default:B(()=>[q($(E.value==="create"?"Create Asset":"Update Asset"),1)]),_:1},8,["loading"])])])]),default:B(()=>{var p;return[g.value?(k(),R("div",Ps,[r("div",Os,[r("div",null,[a[51]||(a[51]=r("h4",{class:"text-sm font-medium text-blue-900"},"Restore Previous Data",-1)),r("p",Ls," You have unsaved changes from "+$(new Date((p=O.value)==null?void 0:p.timestamp).toLocaleString())+". Would you like to restore them? ",1)]),r("div",Fs,[x(C(J),{size:"sm",variant:"primary",onClick:Nt},{default:B(()=>a[52]||(a[52]=[q(" Restore ",-1)])),_:1,__:[52]}),x(C(J),{size:"sm",variant:"secondary",onClick:kt},{default:B(()=>a[53]||(a[53]=[q(" Dismiss ",-1)])),_:1,__:[53]})])])])):W("",!0),x(C(aa),{visible:g.value,"saved-data-info":O.value,onRestore:Nt,onDismiss:kt},null,8,["visible","saved-data-info"]),r("div",Bs,[x(C(Dt),{modelValue:v.value,"onUpdate:modelValue":a[5]||(a[5]=I=>v.value=I),tabs:Ce,onTabChange:kn},null,8,["modelValue"])]),v.value==="basic"?(k(),R("div",Vs,[r("div",Us,[x(Ia,{modelValue:h.value.assetNumber,"onUpdate:modelValue":a[6]||(a[6]=I=>h.value.assetNumber=I),error:m.value.assetNumber},null,8,["modelValue","error"])]),r("div",zs,[x(C(oe),{modelValue:h.value.name,"onUpdate:modelValue":a[7]||(a[7]=I=>h.value.name=I),label:"Asset Name",placeholder:"Enter asset name",required:"",error:m.value.name,onInput:le},null,8,["modelValue","error"]),x(C(ce),{modelValue:h.value.category,"onUpdate:modelValue":a[8]||(a[8]=I=>h.value.category=I),label:"Category",placeholder:"Select category",options:mt.value,required:"",error:m.value.category,onChange:le},null,8,["modelValue","options","error"]),x(C(ce),{modelValue:h.value.status,"onUpdate:modelValue":a[9]||(a[9]=I=>h.value.status=I),label:"Status",placeholder:"Select status",options:rn.value,required:"",error:m.value.status,onChange:le},null,8,["modelValue","options","error"]),x(C(ce),{modelValue:h.value.criticality,"onUpdate:modelValue":a[10]||(a[10]=I=>h.value.criticality=I),label:"Criticality",placeholder:"Select criticality",options:ft.value,required:"",error:m.value.criticality,onChange:le},null,8,["modelValue","options","error"]),x(C(oe),{modelValue:h.value.location,"onUpdate:modelValue":a[11]||(a[11]=I=>h.value.location=I),label:"Location",placeholder:"Enter location",error:m.value.location,onInput:le},null,8,["modelValue","error"])]),r("div",null,[a[54]||(a[54]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Description",-1)),zn(r("textarea",{"onUpdate:modelValue":a[12]||(a[12]=I=>h.value.description=I),class:ne(["w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",{"border-red-300":m.value.description}]),placeholder:"Describe the asset's purpose and characteristics",rows:"3",onInput:le},null,34),[[Hn,h.value.description]]),m.value.description?(k(),R("p",Hs,$(m.value.description),1)):W("",!0)])])):W("",!0),v.value==="financial"?(k(),R("div",$s,[r("div",js,[x(C(oe),{modelValue:h.value.purchasePrice,"onUpdate:modelValue":a[13]||(a[13]=I=>h.value.purchasePrice=I),modelModifiers:{number:!0},type:"number",label:"Purchase Price",placeholder:"0.00",step:"0.01",min:"0",error:m.value.purchasePrice},null,8,["modelValue","error"]),x(C(oe),{modelValue:h.value.currentValue,"onUpdate:modelValue":a[14]||(a[14]=I=>h.value.currentValue=I),modelModifiers:{number:!0},type:"number",label:"Current Value",placeholder:"0.00",step:"0.01",min:"0",error:m.value.currentValue},null,8,["modelValue","error"]),x(C(oe),{modelValue:h.value.purchaseDate,"onUpdate:modelValue":a[15]||(a[15]=I=>h.value.purchaseDate=I),type:"date",label:"Purchase Date",error:m.value.purchaseDate},null,8,["modelValue","error"]),x(C(oe),{modelValue:h.value.installationDate,"onUpdate:modelValue":a[16]||(a[16]=I=>h.value.installationDate=I),type:"date",label:"Installation Date",error:m.value.installationDate},null,8,["modelValue","error"]),x(C(oe),{modelValue:h.value.vendor,"onUpdate:modelValue":a[17]||(a[17]=I=>h.value.vendor=I),label:"Vendor/Supplier",placeholder:"Enter vendor name",error:m.value.vendor},null,8,["modelValue","error"]),x(C(oe),{modelValue:h.value.model,"onUpdate:modelValue":a[18]||(a[18]=I=>h.value.model=I),label:"Model/Part Number",placeholder:"Enter model number",error:m.value.model},null,8,["modelValue","error"])])])):W("",!0),v.value==="warranty"?(k(),R("div",Ys,[x(Jn,{modelValue:h.value.warranty,"onUpdate:modelValue":a[19]||(a[19]=I=>h.value.warranty=I),onValidationChange:xn},null,8,["modelValue"])])):W("",!0),v.value==="custom"?(k(),R("div",Gs,[x(Kn,{modelValue:h.value.customFields,"onUpdate:modelValue":a[20]||(a[20]=I=>h.value.customFields=I),onValidationChange:_n},null,8,["modelValue"])])):W("",!0),v.value==="attachments"?(k(),R("div",qs,[r("div",null,[a[55]||(a[55]=r("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Primary Image ",-1)),a[56]||(a[56]=r("p",{class:"text-sm text-gray-500 mb-3"}," Upload a main image that represents this asset (equipment photos, identification images, etc.) ",-1)),x(C(Pt),{modelValue:h.value.image,"onUpdate:modelValue":a[21]||(a[21]=I=>h.value.image=I),accept:"image/*",multiple:!1,uploading:re.value,"upload-progress":L.value,onFilesAdded:bn},null,8,["modelValue","uploading","upload-progress"])]),r("div",null,[a[63]||(a[63]=r("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Additional Files ",-1)),a[64]||(a[64]=r("p",{class:"text-sm text-gray-500 mb-3"}," Upload manuals, documentation, additional photos, or other relevant files ",-1)),r("div",Qs,[a[58]||(a[58]=r("svg",{class:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48"},[r("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),r("div",Ws,[r("label",Js,[a[57]||(a[57]=r("span",{class:"mt-2 block text-sm font-medium text-gray-900"}," Drop files here or click to upload ",-1)),r("input",{type:"file",class:"sr-only",multiple:"",accept:"image/*,application/pdf,.doc,.docx,.txt",onChange:En},null,32)])]),a[59]||(a[59]=r("p",{class:"mt-2 text-xs text-gray-500"}," PNG, JPG, PDF, DOC, TXT up to 10MB each (max 10 files) ",-1))]),h.value.files&&h.value.files.length>0?(k(),R("div",Ks,[(k(!0),R(Qe,null,We(h.value.files,(I,te)=>(k(),R("div",{key:te,class:"flex items-center justify-between p-3 bg-gray-50 rounded-lg border"},[r("div",Xs,[a[60]||(a[60]=r("svg",{class:"w-5 h-5 text-gray-400 mr-3",fill:"currentColor",viewBox:"0 0 20 20"},[r("path",{"fill-rule":"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z","clip-rule":"evenodd"})],-1)),r("div",null,[r("span",Zs,$(I.name||"Untitled File"),1),r("div",er,$(Sn(I.size||0))+" • Uploaded "+$(Nn(I.uploadedAt)),1)])]),x(C(J),{variant:"ghost",size:"sm",onClick:fe=>Mn(te),class:"text-red-600 hover:text-red-800"},{default:B(()=>a[61]||(a[61]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])),_:2,__:[61]},1032,["onClick"])]))),128))])):W("",!0),r("div",tr,[r("details",null,[a[62]||(a[62]=r("summary",{class:"cursor-pointer hover:text-gray-700"},"Alternative Upload Method",-1)),r("div",nr,[x(C(Pt),{modelValue:h.value.files,"onUpdate:modelValue":a[22]||(a[22]=I=>h.value.files=I),accept:"image/*,application/pdf,.doc,.docx,.txt",multiple:!0,"max-files":10,uploading:re.value,"upload-progress":L.value,onFilesAdded:In},null,8,["modelValue","uploading","upload-progress"])])])])])])):W("",!0),v.value==="qr"?(k(),R("div",ar,[x(Oo,{"asset-data":h.value,"auto-generate":!0,onQrGenerated:Rn},null,8,["asset-data"])])):W("",!0)]}),_:1},8,["modelValue","title","size"]),x(C(Rt),{modelValue:T.value,"onUpdate:modelValue":a[26]||(a[26]=p=>T.value=p),title:"Asset AI Analysis",size:C(b)?"full":"xl"},{content:B(()=>[F.value?(k(),R("div",mr,[r("div",fr,[a[74]||(a[74]=r("h3",{class:"text-lg font-medium text-gray-900 mb-3"},"Health Assessment",-1)),r("div",gr,[r("div",vr,[r("div",{class:ne(["text-2xl font-bold",je(F.value.healthScore)])},$(F.value.healthScore)+"% ",3),a[70]||(a[70]=r("div",{class:"text-sm text-gray-600"},"Overall Health",-1))]),r("div",pr,[r("div",hr,$(F.value.efficiency||"N/A")+"% ",1),a[71]||(a[71]=r("div",{class:"text-sm text-gray-600"},"Efficiency",-1))]),r("div",yr,[r("div",wr,$(F.value.reliability||"N/A")+"% ",1),a[72]||(a[72]=r("div",{class:"text-sm text-gray-600"},"Reliability",-1))]),r("div",Cr,[r("div",{class:ne(["text-2xl font-bold",An(F.value.riskLevel)])},$(F.value.riskLevel),3),a[73]||(a[73]=r("div",{class:"text-sm text-gray-600"},"Risk Level",-1))])])]),F.value.recommendations?(k(),R("div",Ar,[a[76]||(a[76]=r("h3",{class:"text-lg font-medium text-gray-900 mb-3"},"AI Recommendations",-1)),r("div",br,[(k(!0),R(Qe,null,We(F.value.recommendations,(p,I)=>(k(),R("div",{key:I,class:"flex items-start p-3 bg-blue-50 rounded-lg"},[a[75]||(a[75]=r("svg",{class:"w-5 h-5 text-blue-600 mt-0.5 mr-2 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})],-1)),r("span",Ir,$(p),1)]))),128))])])):W("",!0)])):W("",!0)]),actions:B(()=>[x(C(J),{variant:"secondary",onClick:fn},{default:B(()=>a[77]||(a[77]=[q(" Close ",-1)])),_:1,__:[77]}),x(C(J),{onClick:gn},{default:B(()=>a[78]||(a[78]=[q(" Generate Full Report ",-1)])),_:1,__:[78]})]),_:1},8,["modelValue","size"])]),_:1}))}},Hr=rt(Er,[["__scopeId","data-v-14f305af"]]);export{Hr as default};
|