dphelper 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dphelper.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var U={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var F=__DPH_VERSION__,I=globalThis.dphelper;if(I&&I.version&&I.version<F)try{delete globalThis.dphelper}catch{}var R=Object.getOwnPropertyDescriptor(globalThis,"dphelper");R&&!R.configurable?R.writable&&globalThis.dphelper===void 0&&(globalThis.dphelper={}):Object.defineProperty(globalThis,"dphelper",{value:globalThis.dphelper||{},writable:!0,configurable:!0,enumerable:!1});globalThis.dphelper&&Object.defineProperties(globalThis.dphelper,{_list:{value:{scripts:[],sockets:[],...U},configurable:!0,writable:!0},version:{value:F,configurable:!0,writable:!0},isServer:{value:typeof window>"u",configurable:!0,writable:!0},isBrowser:{value:typeof window<"u",configurable:!0,writable:!0}});var C=globalThis.dphelper;Object.defineProperty(C,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:!1,configurable:!1,enumerable:!1}),r?.lock&&Object.freeze(e[t.name])},writable:!1,configurable:!1,enumerable:!1});Object.defineProperty(C,"setDescription",{value:(e,t)=>{Object.defineProperties(C,{[e.name]:{value:t,writable:!1,configurable:!1,enumerable:!1}}),Object.keys(t).map(r=>(Object.defineProperties(C[e.name],{[r]:{writable:!1,configurable:!1,enumerable:!1}}),null)),C.setProps(C,e,{writable:!1,configurable:!1,enumerable:!1}),C._list.scripts.push(e)}});var te={name:"ai",active:!0,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:!0,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:!0,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},H=e=>e===null||typeof e!="object",L=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
1
+ "use strict";(()=>{var U={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var F="3.2.2",I=globalThis.dphelper;if(I&&I.version&&I.version<F)try{delete globalThis.dphelper}catch{}var R=Object.getOwnPropertyDescriptor(globalThis,"dphelper");R&&!R.configurable?R.writable&&globalThis.dphelper===void 0&&(globalThis.dphelper={}):Object.defineProperty(globalThis,"dphelper",{value:globalThis.dphelper||{},writable:!0,configurable:!0,enumerable:!1});globalThis.dphelper&&Object.defineProperties(globalThis.dphelper,{_list:{value:{scripts:[],sockets:[],...U},configurable:!0,writable:!0},version:{value:F,configurable:!0,writable:!0},isServer:{value:typeof window>"u",configurable:!0,writable:!0},isBrowser:{value:typeof window<"u",configurable:!0,writable:!0}});var C=globalThis.dphelper;Object.defineProperty(C,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:!1,configurable:!1,enumerable:!1}),r?.lock&&Object.freeze(e[t.name])},writable:!1,configurable:!1,enumerable:!1});Object.defineProperty(C,"setDescription",{value:(e,t)=>{Object.defineProperties(C,{[e.name]:{value:t,writable:!1,configurable:!1,enumerable:!1}}),Object.keys(t).map(r=>(Object.defineProperties(C[e.name],{[r]:{writable:!1,configurable:!1,enumerable:!1}}),null)),C.setProps(C,e,{writable:!1,configurable:!1,enumerable:!1}),C._list.scripts.push(e)}});var te={name:"ai",active:!0,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:!0,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:!0,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},H=e=>e===null||typeof e!="object",L=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
2
2
  `)||e.trim()!==e?`"${e.replace(/"/g,'\\"')}"`:e||'""':String(e),A=(e,t=0)=>{let r=" ".repeat(t);if(H(e))return L(e);if(Array.isArray(e)){if(e.length===0)return"[0]:";let n=e[0];if(!H(n)&&!Array.isArray(n)){let o=Object.keys(n),a=`[${e.length}]{${o.join(",")}}:`;for(let i of e){let s=o.map(l=>L(i[l])).join(",");a+=`
3
3
  ${r} ${s}`}return a}else return`[${e.length}]: `+e.map(L).join(",")}else return Object.entries(e).map(([n,o])=>{let a=n.includes(" ")||n.includes(":")?`"${n}"`:n;if(!H(o)){let i=A(o,t+1);return i.startsWith("[")?`${a}${i}`:`${a}:
4
4
  ${r}${i}`}return`${a}: ${L(o)}`}).join(`
@@ -49,7 +49,7 @@ ${r}`)},B={tokenCount:e=>{let t=typeof e=="string"?e:A(e);if(!t)return 0;let r=t
49
49
  d = R \u22C5 c
50
50
  where \u03C6 is latitude, \u03BB is longitude, R is earth's radius (mean radius = 6,371km);
51
51
  note that angles need to be in radians to pass to trig functions!
52
- `,env:"client",subCommand:[]},{name:"polarToCartesian",version:"0.0.2",example:"dphelper.coords.polarToCartesian([centerX, centerY, radius, angleInDegrees])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Convert polar coordinates to Cartesian coordinates",env:"client",subCommand:[]},{name:"mapDegreesToPixels",version:"0.0.2",example:"dphelper.coords.mapDegreesToPixels([degree, minDegree, maxDegree, minPixel, maxPixel, padding])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Map degrees to pixels",env:"client",subCommand:[]}]},O=6371e3,De={degreesToRadians:e=>e*Math.PI/180,latToMeters:e=>Array.isArray(e)?O*Math.cos(e[0])*Math.cos(e[1])/1e3:void 0,toVector:e=>{if(!Array.isArray(e))return;let t=O*Math.cos(e[1]*Math.PI/180)*Math.cos(e[0]*Math.PI/180),r=O*Math.cos(e[1]*Math.PI/180)*Math.sin(e[0]*Math.PI/180),n=O*Math.sin(e[2]*Math.PI/180);return[t,r,n]},convertToDecDegrees:(e,t,r,n)=>{let o=e+t/60+r/3600;return(n==="S"||n==="W")&&(o*=-1),o},distance:(e,t)=>{if(!(Array.isArray(e)&&Array.isArray(t)))return;let r=e[0]*Math.PI/180,n=t[0]*Math.PI/180,o=(t[0]-e[0])*Math.PI/180,a=(t[1]-e[1])*Math.PI/180,i=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(n)*Math.sin(a/2)*Math.sin(a/2),s=2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i)),l=O*s;return{km:Number((l/1e3).toFixed(2)),mi:Number((l/1e3*.621371).toFixed(2)),nMi:Number((l/1e3/1.852).toFixed(2))}},polarToCartesian:(e,t,r,n)=>{let o=(n-90)*Math.PI/180;return{x:e+r*Math.cos(o),y:t+r*Math.sin(o)}},mapDegreesToPixels:(e,t,r,n,o,a)=>{let i=(e-t)/(r-t),s=n+i*(o-n),l=a/20,d=o-(s-a)-l;return d<a?a:d}};dphelper?.setDescription(ve,De);var Y={version:"3.2.0",contributors:[{name:"Dario Passariello",email:"dariopassariello@gmail.com"}],app:{folder:"src",type:"library",port:3e3,code:"dphelper",host:{dev:"http://localhost",prod:"https://biglogic.ca/dphelper"},socket:{url:{tst:"http://localhost:5000/",dev:"http://localhost:5000/",pro:"wss://ws.a51.dev/"}},events:{url:{tst:"http://localhost:5002/",dev:"http://localhost:5002/",pro:"wss://ws.a51.dev/"}},proxy:{api:{tst:"http://localhost:5003/",dev:"http://localhost:5003/",pro:"https://api.a51.dev/"}},url:{dev:"http://localhost/"},cdn:{}}};var xe={name:"credits",active:!0,subCommand:[]},sr=__DPH_VERSION__,Ce=()=>{let e=Y},Se=globalThis.dphelper;Se?.setDescription?.(xe,Ce);var G={en:["January","February","March","April","May","June","July","August","September","October","November","December"],it:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]};var Pe={name:"date",active:!0,subCommand:[{name:"toIso",version:"0.0.2",example:"dphelper.date.toIso(value, 'en')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to ISO format.",env:"both",subCommand:[]},{name:"toMMDDYYYY",version:"0.0.2",example:"dphelper.date.toMMDDYYYY(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to MMDDYYYY format.",env:"both",subCommand:[]},{name:"toYYYYMMDD",version:"0.0.2",example:"dphelper.date.toYYYYMMDD(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to YYYYMMDD format.",env:"both",subCommand:[]},{name:"toHuman",version:"0.0.2",example:"dphelper.date.toHuman(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a human-readable format.",env:"both",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.date.convert(value, format)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a specified format.",env:"both",subCommand:[]},{name:"iso2Epoch",version:"0.0.2",example:"dphelper.date.iso2Epoch(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to epoch time.",env:"both",subCommand:[]},{name:"localIsoTime",version:"0.0.2",example:"dphelper.date.localIsoTime(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the local ISO time for a given date value.",env:"both",subCommand:[]},{name:"utc",version:"0.0.2",example:"dphelper.date.utc()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current UTC time.",env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.date.parse(value, '/')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Parses a date value with a specified separator.",env:"both",subCommand:[]},{name:"year",version:"0.0.2",example:"dphelper.date.year()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current year.",env:"both",subCommand:[]},{name:"addDays",version:"0.0.2",example:"dphelper.date.addDays(date, days)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Adds a specified number of days to a date.",env:"both",subCommand:[]},{name:"dateTimeToString",version:"0.0.2",example:"dphelper.date.dateTimeToString(dateObject)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date object to a string.",env:"both",subCommand:[]},{name:"isoToHuman",version:"0.0.2",example:"dphelper.date.isoToHuman(value, '@')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to a human-readable format with a specified symbol.",env:"both",subCommand:[]},{name:"fullDate",version:"0.0.2",example:"dphelper.date.fullDate()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the full date and time in the format DD-MM-YYYY HH:MM:SS.",env:"both",subCommand:[]},{name:"epoch",version:"0.0.2",example:"dphelper.date.epoch()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current epoch time.",env:"both",subCommand:[]},{name:"diffInDays",version:"0.0.2",example:"dphelper.date.diffInDays(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in days between two dates.",env:"both",subCommand:[]},{name:"diffInWeeks",version:"0.0.2",example:"dphelper.date.diffInWeeks(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in weeks between two dates.",env:"both",subCommand:[]},{name:"diffInMonths",version:"0.0.2",example:"dphelper.date.diffInMonths(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in months between two dates.",env:"both",subCommand:[]},{name:"diffInYears",version:"0.0.2",example:"dphelper.date.diffInYears(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in years between two dates.",env:"both",subCommand:[]},{name:"dateToYMD",version:"0.0.2",example:"dphelper.date.dateToYMD(date)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date to the format YYYY-MM-DD.",env:"both",subCommand:[]},{name:"collection",version:"0.0.2",example:"dphelper.date.collection()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets various date representations based on the type and locale.",env:"both",subCommand:[]},{name:"timeZones",version:"0.0.2",example:"dphelper.date.timeZones()",author:"Dario Passariello",creationDate:"20240901",lastMod:"20260220",type:"function",active:!0,description:"Returns an array of all supported timezones.",env:"both",subCommand:[]}]},ke={days:(e="en")=>({en:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],it:["luned\xEC","marted\xEC","mercoled\xEC","gioved\xEC","venerd\xEC","sabato","domenica"]})[e],months:(e="en")=>G[e],year:()=>new Date().getFullYear(),toIso:(e,t="en")=>{e||(e="");let r=new Date(e);return String(r)==="Invalid Date"?null:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"numeric"}).format(r)},toMMDDYYYY:e=>{try{let t=new Date(e);return isNaN(t.getTime())?"":`0${t.getMonth()+1}`.slice(-2)+""+`0${t.getDate()}`.slice(-2)+t.getFullYear()}catch{return""}},toYYYYMMDD:e=>{if(e)return e.toISOString().split("T")[0].replaceAll("-","")},toHuman:e=>{let t={weekday:"long",year:"numeric",month:"long",day:"numeric"};return e.toLocaleDateString(void 0,t)},convert:(e,t)=>{if(!e)return null;t||(t=dphelper.date.months("en"));let r=e.substring(0,2).replace("0",""),n=e.substring(2,4),o=e.substring(e.length-4);return`${n} ${t[Number(r)-1]} ${o}`},iso2Epoch:e=>(e||(e=""),new Date(e).getTime()),localIsoTime:e=>{e||(e=new Date);let t=new Date(e);if(isNaN(t.getTime()))return"";let r=t.getTimezoneOffset()*6e4;return new Date(Date.now()-r).toISOString().slice(0,-1)},utc:()=>new Date().toUTCString(),parse:(e,t="/")=>{if(!e)return null;let r=e.substring(0,2),n=e.substring(2,4),o=e.substring(4,8);return r+t+n+t+o},addDays:(e,t)=>{let r=new Date(Number(e));return r.setDate(e.getDate()+t),r},dateTimeToString:e=>{try{return`${e.getFullYear()}${e.getMonth().toString().length>1?e.getMonth()+1:`0${e.getMonth()+1}`}
52
+ `,env:"client",subCommand:[]},{name:"polarToCartesian",version:"0.0.2",example:"dphelper.coords.polarToCartesian([centerX, centerY, radius, angleInDegrees])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Convert polar coordinates to Cartesian coordinates",env:"client",subCommand:[]},{name:"mapDegreesToPixels",version:"0.0.2",example:"dphelper.coords.mapDegreesToPixels([degree, minDegree, maxDegree, minPixel, maxPixel, padding])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Map degrees to pixels",env:"client",subCommand:[]}]},O=6371e3,De={degreesToRadians:e=>e*Math.PI/180,latToMeters:e=>Array.isArray(e)?O*Math.cos(e[0])*Math.cos(e[1])/1e3:void 0,toVector:e=>{if(!Array.isArray(e))return;let t=O*Math.cos(e[1]*Math.PI/180)*Math.cos(e[0]*Math.PI/180),r=O*Math.cos(e[1]*Math.PI/180)*Math.sin(e[0]*Math.PI/180),n=O*Math.sin(e[2]*Math.PI/180);return[t,r,n]},convertToDecDegrees:(e,t,r,n)=>{let o=e+t/60+r/3600;return(n==="S"||n==="W")&&(o*=-1),o},distance:(e,t)=>{if(!(Array.isArray(e)&&Array.isArray(t)))return;let r=e[0]*Math.PI/180,n=t[0]*Math.PI/180,o=(t[0]-e[0])*Math.PI/180,a=(t[1]-e[1])*Math.PI/180,i=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(n)*Math.sin(a/2)*Math.sin(a/2),s=2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i)),l=O*s;return{km:Number((l/1e3).toFixed(2)),mi:Number((l/1e3*.621371).toFixed(2)),nMi:Number((l/1e3/1.852).toFixed(2))}},polarToCartesian:(e,t,r,n)=>{let o=(n-90)*Math.PI/180;return{x:e+r*Math.cos(o),y:t+r*Math.sin(o)}},mapDegreesToPixels:(e,t,r,n,o,a)=>{let i=(e-t)/(r-t),s=n+i*(o-n),l=a/20,d=o-(s-a)-l;return d<a?a:d}};dphelper?.setDescription(ve,De);var Y={contributors:[{name:"Dario Passariello",email:"dariopassariello@gmail.com"}],app:{folder:"src",type:"library",port:3e3,code:"dphelper",host:{dev:"http://localhost",prod:"https://biglogic.ca/dphelper"},socket:{url:{tst:"http://localhost:5000/",dev:"http://localhost:5000/",pro:"wss://ws.a51.dev/"}},events:{url:{tst:"http://localhost:5002/",dev:"http://localhost:5002/",pro:"wss://ws.a51.dev/"}},proxy:{api:{tst:"http://localhost:5003/",dev:"http://localhost:5003/",pro:"https://api.a51.dev/"}},url:{dev:"http://localhost/"},cdn:{}}};var xe={name:"credits",active:!0,subCommand:[]};var Ce=()=>{let e=Y},Se=globalThis.dphelper;Se?.setDescription?.(xe,Ce);var G={en:["January","February","March","April","May","June","July","August","September","October","November","December"],it:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]};var Pe={name:"date",active:!0,subCommand:[{name:"toIso",version:"0.0.2",example:"dphelper.date.toIso(value, 'en')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to ISO format.",env:"both",subCommand:[]},{name:"toMMDDYYYY",version:"0.0.2",example:"dphelper.date.toMMDDYYYY(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to MMDDYYYY format.",env:"both",subCommand:[]},{name:"toYYYYMMDD",version:"0.0.2",example:"dphelper.date.toYYYYMMDD(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to YYYYMMDD format.",env:"both",subCommand:[]},{name:"toHuman",version:"0.0.2",example:"dphelper.date.toHuman(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a human-readable format.",env:"both",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.date.convert(value, format)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a specified format.",env:"both",subCommand:[]},{name:"iso2Epoch",version:"0.0.2",example:"dphelper.date.iso2Epoch(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to epoch time.",env:"both",subCommand:[]},{name:"localIsoTime",version:"0.0.2",example:"dphelper.date.localIsoTime(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the local ISO time for a given date value.",env:"both",subCommand:[]},{name:"utc",version:"0.0.2",example:"dphelper.date.utc()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current UTC time.",env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.date.parse(value, '/')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Parses a date value with a specified separator.",env:"both",subCommand:[]},{name:"year",version:"0.0.2",example:"dphelper.date.year()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current year.",env:"both",subCommand:[]},{name:"addDays",version:"0.0.2",example:"dphelper.date.addDays(date, days)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Adds a specified number of days to a date.",env:"both",subCommand:[]},{name:"dateTimeToString",version:"0.0.2",example:"dphelper.date.dateTimeToString(dateObject)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date object to a string.",env:"both",subCommand:[]},{name:"isoToHuman",version:"0.0.2",example:"dphelper.date.isoToHuman(value, '@')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to a human-readable format with a specified symbol.",env:"both",subCommand:[]},{name:"fullDate",version:"0.0.2",example:"dphelper.date.fullDate()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the full date and time in the format DD-MM-YYYY HH:MM:SS.",env:"both",subCommand:[]},{name:"epoch",version:"0.0.2",example:"dphelper.date.epoch()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current epoch time.",env:"both",subCommand:[]},{name:"diffInDays",version:"0.0.2",example:"dphelper.date.diffInDays(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in days between two dates.",env:"both",subCommand:[]},{name:"diffInWeeks",version:"0.0.2",example:"dphelper.date.diffInWeeks(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in weeks between two dates.",env:"both",subCommand:[]},{name:"diffInMonths",version:"0.0.2",example:"dphelper.date.diffInMonths(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in months between two dates.",env:"both",subCommand:[]},{name:"diffInYears",version:"0.0.2",example:"dphelper.date.diffInYears(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in years between two dates.",env:"both",subCommand:[]},{name:"dateToYMD",version:"0.0.2",example:"dphelper.date.dateToYMD(date)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date to the format YYYY-MM-DD.",env:"both",subCommand:[]},{name:"collection",version:"0.0.2",example:"dphelper.date.collection()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets various date representations based on the type and locale.",env:"both",subCommand:[]},{name:"timeZones",version:"0.0.2",example:"dphelper.date.timeZones()",author:"Dario Passariello",creationDate:"20240901",lastMod:"20260220",type:"function",active:!0,description:"Returns an array of all supported timezones.",env:"both",subCommand:[]}]},ke={days:(e="en")=>({en:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],it:["luned\xEC","marted\xEC","mercoled\xEC","gioved\xEC","venerd\xEC","sabato","domenica"]})[e],months:(e="en")=>G[e],year:()=>new Date().getFullYear(),toIso:(e,t="en")=>{e||(e="");let r=new Date(e);return String(r)==="Invalid Date"?null:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"numeric"}).format(r)},toMMDDYYYY:e=>{try{let t=new Date(e);return isNaN(t.getTime())?"":`0${t.getMonth()+1}`.slice(-2)+""+`0${t.getDate()}`.slice(-2)+t.getFullYear()}catch{return""}},toYYYYMMDD:e=>{if(e)return e.toISOString().split("T")[0].replaceAll("-","")},toHuman:e=>{let t={weekday:"long",year:"numeric",month:"long",day:"numeric"};return e.toLocaleDateString(void 0,t)},convert:(e,t)=>{if(!e)return null;t||(t=dphelper.date.months("en"));let r=e.substring(0,2).replace("0",""),n=e.substring(2,4),o=e.substring(e.length-4);return`${n} ${t[Number(r)-1]} ${o}`},iso2Epoch:e=>(e||(e=""),new Date(e).getTime()),localIsoTime:e=>{e||(e=new Date);let t=new Date(e);if(isNaN(t.getTime()))return"";let r=t.getTimezoneOffset()*6e4;return new Date(Date.now()-r).toISOString().slice(0,-1)},utc:()=>new Date().toUTCString(),parse:(e,t="/")=>{if(!e)return null;let r=e.substring(0,2),n=e.substring(2,4),o=e.substring(4,8);return r+t+n+t+o},addDays:(e,t)=>{let r=new Date(Number(e));return r.setDate(e.getDate()+t),r},dateTimeToString:e=>{try{return`${e.getFullYear()}${e.getMonth().toString().length>1?e.getMonth()+1:`0${e.getMonth()+1}`}
53
53
  ${e.getDate().toString().length>1?e.getDate():`0${e.getDate()}`}_${e.getHours()}${e.getMinutes()}${e.getSeconds()}`}catch{return e}},isoToHuman:(e,t="@")=>{if(!e)return null;let r=dphelper.date.months("en"),n=new Date(e),o=n.getFullYear(),a=e.split("T")[1].split(":").slice(0,2).join(":"),i=(n.getMonth()+1).toString(),s=n.getDate().toString();return s.length<2&&(s=`0${s}`),i.length<2&&(i=`0${i}`),`${s} ${r[Number(i)-1]} ${o} ${t} ${a}`},fullDate:()=>{let e=new Date,t=Number(e.getDate()),r=Number(e.getMonth()+1),n=Number(e.getFullYear()),o=Number(e.getHours()),a=Number(e.getMinutes()),i=Number(e.getSeconds());return(t<10?`0${t}`:t)+"-"+(r<10?`0${r}`:r)+"-"+n+" "+(o<10?`0${o}`:o)+":"+(a<10?`0${a}`:a)+":"+(i<10?`0${i}`:i)},epoch:()=>Date.now(),diffInDays:(e,t)=>{let r=t.getTime(),n=e.getTime();return Math.floor((r-n)/(24*3600*1e3))},diffInWeeks:(e,t)=>{let r=t.getTime(),n=e.getTime();return Number(Number.parseInt(String((r-n)/(24*3600*1e3*7)),10))},diffInMonths:(e,t)=>{let r=e.getFullYear(),n=t.getFullYear(),o=e.getMonth();return t.getMonth()+12*n-(o+12*r)},diffInYears:(e,t)=>t.getFullYear()-e.getFullYear(),dateToYMD:e=>{let t=e.getDate(),r=e.getMonth()+1;return`${e.getFullYear()}-${r<=9?`0${r}`:r}-${t<=9?`0${t}`:t}`},collection:({date:e=new Date,type:t="",locale:r="en-US"})=>{let n;switch(t){case"toDateString":n=e.toDateString();break;case"toISOString":n=e.toISOString();break;case"toJSON":n=e.toJSON();break;case"toLocaleDateString":n=e.toLocaleDateString(r);break;case"toLocaleString":n=e.toLocaleString(r);break;case"toLocaleTimeString":n=e.toLocaleTimeString(r);break;case"toString":n=e.toString();break;case"toISOStringShort":n=e.toISOString().slice(0,10);break}return n},timeZones:()=>{let e=[],t=Intl.supportedValuesOf("timeZone");for(let r of t)e.push(r);return e}};dphelper?.setDescription(Pe,ke);var Te={name:"disable",active:!0,subCommand:[{name:"select",version:"0.0.2",example:"dphelper.disable.select([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable text selection on the specified element.",env:"client",subCommand:[]},{name:"spellCheck",version:"0.0.2",example:"dphelper.disable.spellCheck([tmr = 5000])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable spell check on the specified element after a delay.",env:"client",subCommand:[]},{name:"rightClick",version:"0.0.2",example:"dphelper.disable.rightClick([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable right-click context menu on the specified element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.disable.copy([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable copy functionality on the specified element.",env:"client",subCommand:[]},{name:"paste",version:"0.0.2",example:"dphelper.disable.paste([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable paste functionality on the specified element.",env:"client",subCommand:[]},{name:"cut",version:"0.0.2",example:"dphelper.disable.cut([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable cut functionality on the specified element.",env:"client",subCommand:[]},{name:"drag",version:"0.0.2",example:"dphelper.disable.drag([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable drag functionality on the specified element.",env:"client",subCommand:[]}]},Ee={select:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;if(!t||typeof t.addEventListener!="function")return;let r=n=>{let o=n.target,a=o.tagName.toLowerCase();if(!["input","button","select","textarea"].includes(a)&&!o.classList.contains("selectable"))return document.querySelectorAll("*").forEach(i=>i.blur()),n.preventDefault(),!1;document.querySelectorAll("img, a, input, button").forEach(i=>{i.addEventListener("dragstart",s=>(s.preventDefault(),!1))})};t.addEventListener("mousedown",r)}catch{}},spellCheck:(e=5e3)=>{setInterval(()=>{let r=document.querySelectorAll("input[type=text], textarea, code");for(let n of r)n.getAttribute("spellcheck")||n.setAttribute("spellcheck","false")},e)},rightClick:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("contextmenu",r=>r.preventDefault())}catch{}},copy:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("copy",r=>r.preventDefault())}catch{}},paste:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("paste",r=>r.preventDefault())}catch{}},cut:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("cut",r=>r.preventDefault())}catch{}},drag:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("dragstart",r=>r.preventDefault())}catch{}}};dphelper?.setDescription?.(Te,Ee);var S={},Ae={name:"dispatch",active:!0,subCommand:[{name:"set",version:"0.0.2",example:"dphelper.dispatch.set([name, value])",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:!0,description:"Dispatches a custom event with the specified name and value.",env:"client",subCommand:[]},{name:"listen",version:"0.0.2",example:"dphelper.dispatch.listen([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:!0,description:"Listens for the specified event names and executes the callback when the event is triggered.",env:"client",subCommand:[]},{name:"remove",version:"0.0.2",example:"dphelper.dispatch.remove([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:!0,description:"Removes the event listener for the specified event names.",env:"client",subCommand:[]}]},Oe={set:(e,t={})=>dispatchEvent(new CustomEvent(String(e),t)),listen:(e,t)=>{S[e]&&S[e].length>0&&dphelper.dispatch.remove(e);let r=n=>t?setTimeout(()=>t(n),0):null;window.addEventListener(e,r),S[e]||(S[e]=[]),S[e].push(r)},remove:e=>{let t=S[e];t&&(t.forEach(r=>window.removeEventListener(e,r)),delete S[e])}};dphelper?.setDescription(Ae,Oe);var Le={name:"element",active:!0,subCommand:[{name:"fitScale",version:"0.0.2",example:"dphelper.element.fitScale([el = 'root', scale = 1, fit = false])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Scales an element based on the window size.",env:"client",subCommand:[]}]},Ne={fitScale:(e,t=1,r=!1)=>addEventListener("resize",n=>dphelper.element.scaleBasedOnWindow(e,t,r)),scaleBasedOnWindow:(e,t,r)=>{if(!e)return;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return;let o=n.offsetWidth||1,a=n.offsetHeight||1,i=r?t/Math.max(o/window.innerWidth,a/window.innerHeight):t/Math.min(o/window.innerWidth,a/window.innerHeight);n.style.transform=`scale(${i})`}};dphelper?.setDescription(Le,Ne);var je={name:"event",active:!0,subCommand:[{name:"list",version:"0.0.2",example:"dphelper.event.list([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Show attached events.",env:"client",subCommand:[]},{name:"multi",version:"0.0.2",example:"dphelper.event.multi([element, eventNames, listener])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Attach multiple event listeners to an element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.event.copy([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Copy text content of an element to the clipboard.",env:"client",subCommand:[]},{name:"onDrag",version:"0.0.2",example:"dphelper.event.onDrag([element])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Handle dragging functionality for elements.",env:"client",subCommand:[]},{name:"keys",version:"0.0.2",example:"dphelper.event.keys(e)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Return key event properties.",env:"client",subCommand:[]}]},$e={list:e=>window.getEventListeners(e),multi:(e,t,r)=>{let n=t.split(" ");for(let o of n)e.addEventListener(o,r,!1)},copy:e=>{let t=document.querySelector(e);t&&t.addEventListener("click",async r=>{if(navigator.clipboard)try{let n=r.target;n&&(await navigator.clipboard.writeText(n.textContent||""),alert("Copied"))}catch{}})},onDrag:e=>{let t=`.popup_overflow_${e}`,r=document.querySelector(t);if(!r)return;let n=o=>{let a=document.querySelector(t),i=a?.offsetHeight||0,s=a?.offsetWidth||0,l=Math.max(o.pageY,0)-i/2,d=Math.max(o.pageX,0)-s/2;localStorage.setItem(e,JSON.stringify([l,d]))};r.addEventListener("mousedown",()=>{window.addEventListener("mousemove",n)}),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",n)})},keys:e=>({key:e.key,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})};dphelper?.setDescription(je,$e);var qe={name:"fetch",active:!0,subCommand:[{name:"get",version:"0.0.1",example:"dphelper.fetch.get('https://api.example.com')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Perform a GET request with automatic retries and exponential backoff.",env:"both",subCommand:[]},{name:"post",version:"0.0.1",example:"dphelper.fetch.post('/api', { data: 123 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Perform a POST request with JSON support.",env:"both",subCommand:[]}]},N=async(e,t={},r=3,n=1e3)=>{try{let o=await globalThis.fetch(e,t);if(!o.ok&&r>0)throw new Error(o.statusText);return o}catch(o){if(r===0)throw o;return await new Promise(a=>setTimeout(a,n)),N(e,t,r-1,n*2)}},_=(e,t)=>N(e,t);_.get=(e,t)=>N(e,{...t,method:"GET"});_.post=(e,t,r={})=>{let n=typeof t=="object"&&t!==null;return N(e,{...r,method:"POST",headers:{...n?{"Content-Type":"application/json"}:{},...r.headers||{}},body:n?JSON.stringify(t):t})};dphelper?.setDescription(qe,_);var Ie={name:"form",active:!0,subCommand:[{name:"serialize",version:"0.0.2",example:"dphelper.form.serialize([form])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Serialize form data into an object.",env:"client",subCommand:[]},{name:"confirmType",version:"0.0.2",example:"dphelper.form.confirmType([type, value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Confirm the type of a value.",env:"client",subCommand:[]},{name:"required",version:"0.0.2",example:"dphelper.form.required([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value is required.",env:"client",subCommand:[]},{name:"minLength",version:"0.0.2",example:"dphelper.form.minLength([value, num = 1])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value meets the minimum length.",env:"client",subCommand:[]},{name:"maxLength",version:"0.0.2",example:"dphelper.form.maxLength([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value exceeds the maximum length.",env:"client",subCommand:[]},{name:"maxPhoneNumber",version:"0.0.2",example:"dphelper.form.maxPhoneNumber([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a phone number exceeds the maximum length.",env:"client",subCommand:[]},{name:"isNumeric",version:"0.0.2",example:"dphelper.form.isNumeric([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value is numeric.",env:"client",subCommand:[]},{name:"isEmail",version:"0.0.2",example:"dphelper.form.isEmail([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Validate an email format.",env:"client",subCommand:[]},{name:"pattern",version:"0.0.2",example:"dphelper.form.pattern(event)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Pattern validation using onChange on inputs when you provide a pattern.",env:"client",subCommand:[]},{name:"noSpecialChars",version:"0.0.2",example:"dphelper.form.noSpecialChars(event)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Avoid special characters in an input.",env:"client",subCommand:[]},{name:"table",version:"0.0.2",example:"dphelper.form.table(size = [7, 24], id, elem)",author:"Dario Passariello",creationDate:"20240101",lastMod:"20240101",type:"function",active:!0,description:"Generate a table (default 7x24).",env:"client",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.form.sanitize(input)",author:"Dario Passariello",creationDate:"20240318",lastMod:"20240318",type:"function",active:!0,description:"Sanitize input value to avoid injection.",env:"client",subCommand:[]}]},Re={serialize:e=>{let t=typeof e=="string"?document.querySelector(e):e;if(!t)return{};let r={};if(!{validate:/[a-zA-Z][a-zA-Z0-9-_.]/,key:/[a-zA-Z0-9_]+|(?=\[\])/g,push:/^$/,fixed:/^\d+$/,named:/^[a-zA-Z0-9_]+$/}.validate.test(t.name))return;let o=s=>(s===""&&(s=null),s==="null"&&(s=null),s==="undefined"&&(s=void 0),s==="false"&&(s=!1),s==="true"&&(s=!0),s==="off"&&(s=!1),s==="on"&&(s=!0),s==="[]"&&(s=Array),s==="{}"&&(s=Object),["null","undefined","false","true","on","off"].filter(c=>c.includes(s)).length===0&&!Number.isNaN(s)&&(s=Number(s)),s),a=(s,l)=>{let d=s[0];d.slice(-1)==="]"&&(d=d.slice(0,-1));let c={};return s.length===1?c[d]=o(l):(s.shift(),c[d]=a(s,l)),c},i=t.serializeArray();for(let s of i){let l=s.value,d=s.name.split("["),c=a(d,l);Object.assign(r,c)}return r},confirmType:(e,t)=>e==="number"?/^\d+$/.test(t.toString()):e==="email"?/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t.toString().toLowerCase()):!0,required:e=>e==null?"Required":void 0,minLength:(e,t=1)=>!e||e.length<t?"Must Enter a Value":void 0,maxLength:(e,t=10)=>e.length>t?"Exceeds Max Length":void 0,maxPhoneNumber:(e,t=10)=>e.toString().length>t?"Exceeds Max Length":void 0,isNumeric:e=>!Number.isNaN(e),isEmail:e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e.toString().toLowerCase()),pattern:e=>{let t=e.target;if(!(t.type&&t.value))return;let r;switch(t.type){case"text":case"password":r=/^[a-zA-Z0-9.\- !$@]+$/;break;case"email":r=/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/;break;case"number":r=/^[0-9\-+]*$/;break;case"tel":r=/^[0-9\s()\-+]*$/;break;default:return}t.value.match(r)||(t.value=t.value.slice(0,-1),e.preventDefault())},noSpecialChars:e=>{let t=e.target,r=t.value.trim(),n=/[^\w\s]/gi;r.length>2&&(t.value=r.replace(n,""))},table:(e,t,r)=>{let n=e[0]||7,o=e[1]||24,a=s=>String(s).replace(/[&<>"']/g,l=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[l]||l),i=`<form id='${a(t)}'>`;i+="<div class='table'>",i+="<div class='title'>";for(let s=1;s<=n;s++)i+=`<span>${s}</span>`;i+="</div>";for(let s=1;s<=o;s++){i+=`<div class='row'><span>${s}</span>`;for(let l=1;l<=n;l++)i+=`<input name='data[${l}][${s}]' tabindex='${l.toString().padStart(2,"0")}${s.toString().padStart(2,"0")}' type='number' onclick="this.select()" value='${Math.floor(Math.random()*100)}' title='${a(l)} to ${a(s)}' />`;i+="</div>"}i+="</div>",i+="</form>",r&&(r.innerHTML=i)},sanitize:e=>{if(e)return e.replace(/[^\w ]/g,"").replace(/[&/\\#, +()$~%.'":*?<>{}]/g,"")}};dphelper?.setDescription(Ie,Re);var He={name:"format",active:!0,subCommand:[{name:"currency",version:"0.0.2",example:"dphelper.format.currency(value, locale, currency)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Format a number as currency.",env:"both",subCommand:[]},{name:"phoneNumber",version:"0.0.2",example:"dphelper.format.phoneNumber(value, countryCode)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Format a string as a phone number.",env:"both",subCommand:[]}]},_e={currency:(e,t="en-US",r="USD")=>new Intl.NumberFormat(t,{style:"currency",currency:r}).format(e),phoneNumber:(e,t="US")=>{let r=`${e}`.replace(/\D/g,""),n;return t==="US"&&(n=r.match(/^(\d{3})(\d{3})(\d{4})$/),n)?`(${n[1]}) ${n[2]}-${n[3]}`:e}};dphelper?.setDescription(He,_e);var ze={name:"json",active:!0,subCommand:[{name:"counter",version:"0.0.2",example:"dphelper.json.counter()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Count occurrences of a key-value pair in a JSON object.",env:"both",subCommand:[]},{name:"toCsv",version:"0.0.2",example:"dphelper.json.toCsv()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Convert JSON data to CSV format.",env:"both",subCommand:[]},{name:"saveCsvAs",version:"0.0.2",example:"dphelper.json.saveCsvAs()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Save CSV data as a file.",env:"both",subCommand:[]},{name:"is",version:"0.0.2",example:"dphelper.json.is()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a string is valid JSON.",env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.json.parse()",author:"Dario Passariello",creationDate:"20241107",lastMod:"20241107",type:"function",active:!0,description:"Parse a JSON string.",env:"both",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.json.sanitize()",author:"Dario Passariello",creationDate:"20241107",lastMod:"20241107",type:"function",active:!0,description:"Sanitize a JSON string.",env:"both",subCommand:[]},{name:"sanitizeJsonValue",version:"0.0.2",example:"dphelper.json.sanitizeJsonValue()",author:"Dario Passariello",creationDate:"20241107",lastMod:"20241107",type:"function",active:!0,description:"Sanitize individual JSON values.",env:"both",subCommand:[]}]},Ue={counter:(e,t,r)=>e?t&&r?e.items&&Array.isArray(e.items)?e.items.filter(n=>n[t]===r).length:Object.keys(e).length:0:null,toCsv:e=>{let t=e,r=(a,i)=>i===null?"":i,n=Object.keys(t[0]),o=t.map(a=>n.map(i=>JSON.stringify(a[i],r)).join(","));return o.unshift(n.join(",")),o.join(`\r
54
54
  `)},saveCsvAs:(e,t)=>{let r=new Blob([e],{type:"text/csv;charset=utf-8;"}),n=document.createElement("a"),o=dphelper.date.dateTimeToString(new Date(Date.now())),a=`${t}_${o}.csv`,i=URL.createObjectURL(r);n.setAttribute("href",i),n.setAttribute("download",a),n.style.visibility="hidden",document.body.appendChild(n),n.click(),document.body.removeChild(n)},is:e=>{try{JSON.parse(e)}catch{return!1}return!0},parse:e=>{try{return JSON.parse(e)}catch{return"Json not parsable"}},sanitize:e=>e?"{"+e.trim().replace(/^\{/,"").replace(/\}$/,"").split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/).map(o=>{let[a,...i]=o.split(":"),s=dphelper.json.sanitizeJsonValue(a?.trim()??"");if(!a)return"";let l=i.join(":");return l?(l=l.trim(),l==="null"?l='""':l==="true"||l==="false"?l=`"${l}"`:/^\d+$/.test(l)?l=`"${l}"`:l=dphelper.json.sanitizeJsonValue(l)):l='""',`${s}:${l}`}).filter(o=>o!=="").join(",")+"}":"{}",sanitizeJsonValue:e=>e?`"${e.replace(/^"(.*)"$/,"$1").replace(/\\/g,"").replace(/\//g,"/").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/"/g,'\\"').replace(/\t/g," ").trim()}"`:'""'};dphelper?.setDescription(ze,Ue);var Fe={name:"load",active:!0,subCommand:[{name:"all",version:"0.0.3",example:"dphelper.load.all(import.meta.glob('./Scripts/*.ts', { eager: true }))",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260228",type:"function",active:!0,description:"Load all files from a glob object (Vite/esbuild) or require context. If you add a 'cacheName', the list is stored in cache.",env:"client",subCommand:[]},{name:"file",version:"0.0.2",example:"dphelper.load.file(filePath)",author:"Dario Passariello",creationDate:"20240101",lastMod:"20240101",type:"function",active:!0,description:"Load a specific file.",env:"client",subCommand:[]},{name:"fileToElement",version:"0.0.2",example:"dphelper.load.fileToElement(filePath, elementSelector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Load a file and insert its content into an element.",env:"client",subCommand:[]},{name:"script",version:"0.0.2",example:"dphelper.load.script(scripts, elementSelector)",author:"Dario Passariello",creationDate:"20240525",lastMod:"20240525",type:"function",active:!0,description:"Append script tags to an element.",env:"client",subCommand:[]},{name:"toJson",version:"0.0.3",example:"dphelper.load.toJson(import.meta.glob('./router/*.ts', { eager: true }), 'router')",author:"Dario Passariello",creationDate:"20250101",lastMod:"20260228",type:"function",active:!0,description:"Create JSON from folder recursion using glob object.",env:"client",subCommand:[]}]},Be={all:(e,t="")=>{if(e){if(t&&!window[t]&&(window[t]=[]),typeof e=="object"&&!e.keys){for(let r in e)t&&window[t].push(r);return}if(typeof e=="function"&&e.keys)for(let r of e.keys())t&&window[t].push(r),e(r)}},file:()=>null,fileToElement:async(e,t)=>{try{let r=await dphelper.load.file(t),n=document.querySelector(e);n&&(n.innerHTML=dphelper.sanitize.html(r))}catch{}},script:(e,t="html")=>{let r=document.querySelector(t);if(r)for(let n of e){let o=document.createElement("script");o.src=n,o.async=!0,o.defer=!0,r.appendChild(o)}},toJson:(e,t="")=>{let r={};if(e){if(t&&(r[t]=[]),typeof e=="object"&&!e.keys)for(let n in e)t&&r[t]&&r[t].push(n);else if(typeof e=="function"&&e.keys)for(let n of e.keys())t&&r[t]&&r[t].push(n),e(n);!t||!r[t]||Object.defineProperty(window,t,{value:dphelper.array.pathToJson(r[t]),writable:!1,enumerable:!1,configurable:!1})}}};dphelper?.setDescription?.(Fe,Be);var Je={name:"logging",active:!0,subCommand:[{name:"list",version:"0.0.2",example:"dphelper.log.list()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"List all log entries.",env:"both",subCommand:[]},{name:"reg",version:"0.0.2",example:"dphelper.log.reg('message')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Log a regular message.",env:"both",subCommand:[]},{name:"debug",version:"0.0.2",example:"dphelper.log.debug('message')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Log a debug message.",env:"both",subCommand:[]},{name:"error",version:"0.0.2",example:"dphelper.log.error('message')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Log an error message.",env:"both",subCommand:[]}]},y={log:[]},Ye={list:()=>y.log,reg:e=>{y.log.push({type:"reg",message:e}),y.log.length>1e3&&y.log.shift()},debug:e=>{y.log.push({type:"debug",message:e}),y.log.length>1e3&&y.log.shift()},error:e=>{y.log.push({type:"error",message:e}),y.log.length>1e3&&y.log.shift()}};Object.defineProperty(y,"log",{writable:!1,enumerable:!1,configurable:!1});dphelper?.setDescription(Je,Ye);var Ge={name:"math",active:!0,subCommand:[{name:"rnd",version:"0.0.2",example:"dphelper.math.rnd()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Generate a random number.",env:"both",subCommand:[]},{name:"tmr",version:"0.0.2",example:"dphelper.math.tmr()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Measure the time taken by a function.",env:"both",subCommand:[]},{name:"isOdd",version:"0.0.2",example:"dphelper.math.isOdd(a)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a number is odd.",env:"both",subCommand:[]},{name:"percent",version:"0.0.2",example:"dphelper.math.percent([n, tot])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculate the percentage of a number relative to a total. Example: total: 100, number: 25 -> 25%",env:"both",subCommand:[]},{name:"isPrime",version:"0.0.2",example:"dphelper.math.isPrime(a)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a number is prime.",env:"both",subCommand:[]}]},We={rnd:()=>Math.floor(1e5+Math.random()*dphelper.math.tmr()),tmr:()=>Math.round(dphelper.date.epoch()/1e3),isOdd:e=>Number(e)%2!==0,percent:(e,t)=>{if(t===0)throw new Error("Total cannot be zero");return Number(e)/Number(t)*100},isPrime:e=>{if(Number(e)<=1)return!1;for(let t=2;t<=Math.sqrt(Number(e));t++)if(Number(e)%t===0)return!1;return!0}};dphelper?.setDescription(Ge,We);var Ve={name:"memory",active:!0,subCommand:[{name:"lock",version:"0.0.2",example:"dphelper.memory.lock('state[key]')",author:"Dario Passariello",creationDate:"20230101",lastMod:"20230111",type:"function",active:!0,description:"Lock a state",env:"client",subCommand:[]},{name:"unlock",version:"0.0.2",example:"dphelper.memory.unlock('state[key]')",author:"Dario Passariello",creationDate:"20230101",lastMod:"20230111",type:"function",active:!0,description:"Unlock a state",env:"client",subCommand:[]}]},Ke={lock:e=>{if(!e)return;let t=window,r=e.split(".");if(r.length<2)return;let n=r[0],o=r[1];if(!n||!o)return;let a=t[n];a&&Object.defineProperty(a,o,{writable:!1,configurable:!1})},unlock:e=>{if(!e)return;let t=window,r=e.split(".");if(r.length<2)return;let n=r[0],o=r[1];if(!n||!o)return;let a=t[n];if(a)try{Object.defineProperty(a,o,{writable:!0,configurable:!0})}catch{}}};dphelper?.setDescription(Ve,Ke);var Ze={name:"navigation",active:!0,subCommand:[{name:"ajax",version:"0.0.2",example:"dphelper.navigation.ajax()",author:"Dario Passariello",creationDate:"20260223",lastMod:"20260223",type:"function",active:!0,description:"Vanilla AJAX Single Page Application (SPA) navigation engine.",env:"client",subCommand:[]},{name:"load",version:"0.0.1",example:"dphelper.navigation.load('/home')",author:"Dario Passariello",creationDate:"20260223",lastMod:"20260223",type:"function",active:!0,description:"Loads a page via AJAX and injects it into the body.",env:"client",subCommand:[]}]},Xe={load:async e=>{let r=document.body,n=e.startsWith("/")?e.split("/")[1]||"home":e;if((!n||n==="")&&(n="home"),!document.querySelector(".loader")){let o=document.createElement("div");o.className="loader",o.innerHTML="<i></i>",o.style.opacity="0",o.style.transition="opacity 1000ms",r.appendChild(o),setTimeout(()=>o.style.opacity="1",10)}try{let o=await fetch(`${n}/`);if(!o.ok)throw new Error("Page not found");let a=await o.text(),i=a.match(/<body[^>]*>([\s\S]*)<\/body>/i),s=i?i[1]:a,l=u=>{let p=document.createElement("div");return p.textContent=u,p.innerHTML},d=dphelper?.sanitize?.html?dphelper.sanitize.html(s||""):l(s||"");r.innerHTML=d,window.scrollTo({top:0,behavior:"smooth"}),document.title=n.charAt(0).toUpperCase()+n.slice(1);let c=dphelper.path.rail();c&&c.length>0&&(r.className=r.className.replace(/path-\w+/g,"").trim(),r.classList.add(`path-${c[c.length-1]}`)),globalThis.dphelper.navigation.ajax_running&&dphelper.navigation.ajax()}catch{let a=window.location.origin;e.startsWith("/")&&!e.startsWith("//")&&!e.match(/^[a-zA-Z]:/)&&new URL(e,a).href.startsWith(a)&&(window.location.href=e)}},_bind:e=>{document.querySelectorAll(e).forEach(r=>{let n=r.getAttribute("href");if(!n||!n.startsWith("/")||n.includes("#"))return;let o=r.cloneNode(!0);r.parentNode?.replaceChild(o,r),o.addEventListener("mouseup",a=>{let i=o.getAttribute("data-href")||n;history.pushState({href:i},"",i),dphelper.navigation.load(i),o.removeAttribute("href"),a.stopPropagation()})})},ajax:()=>{if(globalThis.dphelper.navigation.ajax_running){dphelper.navigation._bind("a");return}globalThis.dphelper.navigation.ajax_running=!0,window.onpopstate=()=>dphelper.navigation.load(window.location.pathname),dphelper.navigation._bind("a"),globalThis.dp_hash_listener_set||(window.addEventListener("hashchange",()=>{let e=window.location.hash.substring(1);e&&document.getElementById(e)?.scrollIntoView({behavior:"smooth"})}),globalThis.dp_hash_listener_set=!0)}};dphelper?.setDescription(Ze,Xe);var Qe={name:"obj",active:!0,subCommand:[{name:"replaceNullObjects",version:"0.0.2",example:"dphelper.obj.replaceNullObjects([obj])",description:"Replace null values in an object with empty objects.",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,env:"both",subCommand:[]},{name:"serialize",version:"0.0.2",example:"dphelper.obj.serialize([obj])",description:"Serialize an object to a JSON string.",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,env:"both",subCommand:[]},{name:"deSerialize",version:"0.0.2",example:"dphelper.obj.deSerialize([obj])",description:"Deserialize a JSON string to an object.",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,env:"both",subCommand:[]},{name:"toXML",version:"0.0.2",example:"dphelper.obj.toXML([obj])",description:"Convert an object to an XML string.",author:"Dario Passariello",creationDate:"20240315",lastMod:"20240315",type:"function",active:!0,env:"both",subCommand:[]},{name:"updateByKey",version:"0.0.2",example:"dphelper.obj.updateByKey([obj, key, newValue])",description:"Update an object's property by key.",author:"Dario Passariello",creationDate:"20240929",lastMod:"20240929",type:"function",active:!0,env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.obj.parse(val)",description:"Check if value is an object or another type. Return object after parse or a different type. Used instead of JSON.parse to avoid crash.",author:"Dario Passariello",creationDate:"20241027",lastMod:"20240927",type:"function",active:!0,env:"both",subCommand:[]},{name:"diff",version:"0.0.2",example:"dphelper.obj.diff([obj1, obj2])",description:"Show the differences between two objects.",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",type:"function",active:!0,env:"both",subCommand:[]},{name:"setProps",version:"0.0.2",example:"dphelper.obj.setProps( [object], {options} )",author:"Dario Passariello",creationDate:"20251224",lastMod:"20251224",type:"function",active:!0,description:"Set properties of an object.",env:"both",subCommand:[]}]},et={replaceNullObjects:e=>{let t={...e};for(let r of Object.keys(e))t[r]===null&&(t[r]="")},serialize:e=>{if(typeof e=="function")return e.toString();if(typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=dphelper.obj.serialize(n);return t}return e},deSerialize:e=>{if(typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=dphelper.obj.deSerialize(n);return t}return e},sort:e=>Object.keys(e).sort().reduce((t,r)=>(t[r]=e[r],t),{}),toXML:e=>{let t=(r,n="")=>{let o="";for(let a in r)if(Object.hasOwn(r,a)){let i=r[a];typeof i=="object"&&i!==null?o+=`${n}<${a}>
55
55
  ${t(i,`${n} `)}${n}</${a}>
@@ -160,4 +160,4 @@ ${t(i,`${n} `)}${n}</${a}>
160
160
  height=${o/d},
161
161
  top=${u},
162
162
  left=${c}
163
- `);onfocus=()=>p?.focus()},onBeforeUnLoad:e=>{let t="You have made some changes which you might want to save.",r=o=>(o.preventDefault(),t),n=e?document.querySelector(e):null;n&&n.addEventListener("input",()=>{n.value!==""?(P=!0,addEventListener("beforeunload",r,{capture:!0})):(P=!1,removeEventListener("beforeunload",r,{capture:!0}))}),Q===!1&&(document.body.addEventListener("click",o=>{let a=o.target;if(a&&a.tagName.toLowerCase()==="img"&&P===!0){if(confirm(t)===!0){P=!1;return}o.preventDefault()}}),Q=!0),addEventListener("popstate",o=>{if(P===!0){if(confirm(t)===!0){P=!1;return}o.stopImmediatePropagation(),o.preventDefault();return}}),onbeforeunload=o=>{if(P===!0)return o.preventDefault(),o.returnValue=t}},purge:(e=document,t=1e4)=>{setTimeout(()=>{if(!e)return;let r=e.attributes;if(r){let n=r.length;for(let o=0;o<n;o+=1){let a=r[o].name;typeof e[a]=="function"&&(e[a]=null),typeof e[a]>"u"&&(e[a]=null)}}if(r=e.childNodes,r){let n=r.length;for(let o=0;o<n;o+=1)dphelper.purge(e.childNodes[o])}},t)},stopZoomWheel:()=>{addEventListener("wheel",e=>{e.ctrlKey&&e.preventDefault()},{passive:!1}),addEventListener("keydown",e=>{let t=dphelper.event.keys(e);["+","-","="].includes(t.key)&&t.ctrl&&e.preventDefault()})},setZoom:(e="html",t=1)=>{t<0&&(t=1);let r=document.querySelector(e);return r&&(r.style.zoom=String(t)),`New zoom value: ${t*100}% (css: ${t})`},getZoom:(e="html")=>{let t=document.querySelector(e);return Number(t?.style.zoom||1)}};dphelper?.setDescription(Xt,Qt);var er=setInterval(()=>{let e=dphelper?.socket?.list(),t=[];e&&(e.map(r=>(t.push(r.url),!1)),dphelper._list.sockets=t,t&&clearInterval(er))},1e3);Object.preventExtensions(dphelper);Object.seal(dphelper);var sn=dphelper;})();
163
+ `);onfocus=()=>p?.focus()},onBeforeUnLoad:e=>{let t="You have made some changes which you might want to save.",r=o=>(o.preventDefault(),t),n=e?document.querySelector(e):null;n&&n.addEventListener("input",()=>{n.value!==""?(P=!0,addEventListener("beforeunload",r,{capture:!0})):(P=!1,removeEventListener("beforeunload",r,{capture:!0}))}),Q===!1&&(document.body.addEventListener("click",o=>{let a=o.target;if(a&&a.tagName.toLowerCase()==="img"&&P===!0){if(confirm(t)===!0){P=!1;return}o.preventDefault()}}),Q=!0),addEventListener("popstate",o=>{if(P===!0){if(confirm(t)===!0){P=!1;return}o.stopImmediatePropagation(),o.preventDefault();return}}),onbeforeunload=o=>{if(P===!0)return o.preventDefault(),o.returnValue=t}},purge:(e=document,t=1e4)=>{setTimeout(()=>{if(!e)return;let r=e.attributes;if(r){let n=r.length;for(let o=0;o<n;o+=1){let a=r[o].name;typeof e[a]=="function"&&(e[a]=null),typeof e[a]>"u"&&(e[a]=null)}}if(r=e.childNodes,r){let n=r.length;for(let o=0;o<n;o+=1)dphelper.purge(e.childNodes[o])}},t)},stopZoomWheel:()=>{addEventListener("wheel",e=>{e.ctrlKey&&e.preventDefault()},{passive:!1}),addEventListener("keydown",e=>{let t=dphelper.event.keys(e);["+","-","="].includes(t.key)&&t.ctrl&&e.preventDefault()})},setZoom:(e="html",t=1)=>{t<0&&(t=1);let r=document.querySelector(e);return r&&(r.style.zoom=String(t)),`New zoom value: ${t*100}% (css: ${t})`},getZoom:(e="html")=>{let t=document.querySelector(e);return Number(t?.style.zoom||1)}};dphelper?.setDescription(Xt,Qt);var er=setInterval(()=>{let e=dphelper?.socket?.list(),t=[];e&&(e.map(r=>(t.push(r.url),!1)),dphelper._list.sockets=t,t&&clearInterval(er))},1e3);Object.preventExtensions(dphelper);Object.seal(dphelper);var an=dphelper;})();
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var F={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var B="3.2.0",R=globalThis.dphelper;if(R&&R.version&&R.version<B)try{delete globalThis.dphelper}catch{}var H=Object.getOwnPropertyDescriptor(globalThis,"dphelper");H&&!H.configurable?H.writable&&globalThis.dphelper===void 0&&(globalThis.dphelper={}):Object.defineProperty(globalThis,"dphelper",{value:globalThis.dphelper||{},writable:!0,configurable:!0,enumerable:!1});globalThis.dphelper&&Object.defineProperties(globalThis.dphelper,{_list:{value:{scripts:[],sockets:[],...F},configurable:!0,writable:!0},version:{value:B,configurable:!0,writable:!0},isServer:{value:typeof window>"u",configurable:!0,writable:!0},isBrowser:{value:typeof window<"u",configurable:!0,writable:!0}});var S=globalThis.dphelper;Object.defineProperty(S,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:!1,configurable:!1,enumerable:!1}),r?.lock&&Object.freeze(e[t.name])},writable:!1,configurable:!1,enumerable:!1});Object.defineProperty(S,"setDescription",{value:(e,t)=>{Object.defineProperties(S,{[e.name]:{value:t,writable:!1,configurable:!1,enumerable:!1}}),Object.keys(t).map(r=>(Object.defineProperties(S[e.name],{[r]:{writable:!1,configurable:!1,enumerable:!1}}),null)),S.setProps(S,e,{writable:!1,configurable:!1,enumerable:!1}),S._list.scripts.push(e)}});var re={name:"ai",active:!0,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:!0,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:!0,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},_=e=>e===null||typeof e!="object",N=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
1
+ var F={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var B="3.2.2",R=globalThis.dphelper;if(R&&R.version&&R.version<B)try{delete globalThis.dphelper}catch{}var H=Object.getOwnPropertyDescriptor(globalThis,"dphelper");H&&!H.configurable?H.writable&&globalThis.dphelper===void 0&&(globalThis.dphelper={}):Object.defineProperty(globalThis,"dphelper",{value:globalThis.dphelper||{},writable:!0,configurable:!0,enumerable:!1});globalThis.dphelper&&Object.defineProperties(globalThis.dphelper,{_list:{value:{scripts:[],sockets:[],...F},configurable:!0,writable:!0},version:{value:B,configurable:!0,writable:!0},isServer:{value:typeof window>"u",configurable:!0,writable:!0},isBrowser:{value:typeof window<"u",configurable:!0,writable:!0}});var S=globalThis.dphelper;Object.defineProperty(S,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:!1,configurable:!1,enumerable:!1}),r?.lock&&Object.freeze(e[t.name])},writable:!1,configurable:!1,enumerable:!1});Object.defineProperty(S,"setDescription",{value:(e,t)=>{Object.defineProperties(S,{[e.name]:{value:t,writable:!1,configurable:!1,enumerable:!1}}),Object.keys(t).map(r=>(Object.defineProperties(S[e.name],{[r]:{writable:!1,configurable:!1,enumerable:!1}}),null)),S.setProps(S,e,{writable:!1,configurable:!1,enumerable:!1}),S._list.scripts.push(e)}});var re={name:"ai",active:!0,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:!0,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:!0,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},_=e=>e===null||typeof e!="object",N=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
2
2
  `)||e.trim()!==e?`"${e.replace(/"/g,'\\"')}"`:e||'""':String(e),O=(e,t=0)=>{let r=" ".repeat(t);if(_(e))return N(e);if(Array.isArray(e)){if(e.length===0)return"[0]:";let n=e[0];if(!_(n)&&!Array.isArray(n)){let o=Object.keys(n),a=`[${e.length}]{${o.join(",")}}:`;for(let i of e){let s=o.map(l=>N(i[l])).join(",");a+=`
3
3
  ${r} ${s}`}return a}else return`[${e.length}]: `+e.map(N).join(",")}else return Object.entries(e).map(([n,o])=>{let a=n.includes(" ")||n.includes(":")?`"${n}"`:n;if(!_(o)){let i=O(o,t+1);return i.startsWith("[")?`${a}${i}`:`${a}:
4
4
  ${r}${i}`}return`${a}: ${N(o)}`}).join(`
@@ -49,7 +49,7 @@ ${r}`)},J={tokenCount:e=>{let t=typeof e=="string"?e:O(e);if(!t)return 0;let r=t
49
49
  d = R \u22C5 c
50
50
  where \u03C6 is latitude, \u03BB is longitude, R is earth's radius (mean radius = 6,371km);
51
51
  note that angles need to be in radians to pass to trig functions!
52
- `,env:"client",subCommand:[]},{name:"polarToCartesian",version:"0.0.2",example:"dphelper.coords.polarToCartesian([centerX, centerY, radius, angleInDegrees])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Convert polar coordinates to Cartesian coordinates",env:"client",subCommand:[]},{name:"mapDegreesToPixels",version:"0.0.2",example:"dphelper.coords.mapDegreesToPixels([degree, minDegree, maxDegree, minPixel, maxPixel, padding])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Map degrees to pixels",env:"client",subCommand:[]}]},L=6371e3,we={degreesToRadians:e=>e*Math.PI/180,latToMeters:e=>Array.isArray(e)?L*Math.cos(e[0])*Math.cos(e[1])/1e3:void 0,toVector:e=>{if(!Array.isArray(e))return;let t=L*Math.cos(e[1]*Math.PI/180)*Math.cos(e[0]*Math.PI/180),r=L*Math.cos(e[1]*Math.PI/180)*Math.sin(e[0]*Math.PI/180),n=L*Math.sin(e[2]*Math.PI/180);return[t,r,n]},convertToDecDegrees:(e,t,r,n)=>{let o=e+t/60+r/3600;return(n==="S"||n==="W")&&(o*=-1),o},distance:(e,t)=>{if(!(Array.isArray(e)&&Array.isArray(t)))return;let r=e[0]*Math.PI/180,n=t[0]*Math.PI/180,o=(t[0]-e[0])*Math.PI/180,a=(t[1]-e[1])*Math.PI/180,i=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(n)*Math.sin(a/2)*Math.sin(a/2),s=2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i)),l=L*s;return{km:Number((l/1e3).toFixed(2)),mi:Number((l/1e3*.621371).toFixed(2)),nMi:Number((l/1e3/1.852).toFixed(2))}},polarToCartesian:(e,t,r,n)=>{let o=(n-90)*Math.PI/180;return{x:e+r*Math.cos(o),y:t+r*Math.sin(o)}},mapDegreesToPixels:(e,t,r,n,o,a)=>{let i=(e-t)/(r-t),s=n+i*(o-n),l=a/20,d=o-(s-a)-l;return d<a?a:d}};dphelper?.setDescription(De,we);var G={version:"3.2.0",contributors:[{name:"Dario Passariello",email:"dariopassariello@gmail.com"}],app:{folder:"src",type:"library",port:3e3,code:"dphelper",host:{dev:"http://localhost",prod:"https://biglogic.ca/dphelper"},socket:{url:{tst:"http://localhost:5000/",dev:"http://localhost:5000/",pro:"wss://ws.a51.dev/"}},events:{url:{tst:"http://localhost:5002/",dev:"http://localhost:5002/",pro:"wss://ws.a51.dev/"}},proxy:{api:{tst:"http://localhost:5003/",dev:"http://localhost:5003/",pro:"https://api.a51.dev/"}},url:{dev:"http://localhost/"},cdn:{}}};var Ce={name:"credits",active:!0,subCommand:[]};var Se=()=>{let e=G},Me=globalThis.dphelper;Me?.setDescription?.(Ce,Se);var W={en:["January","February","March","April","May","June","July","August","September","October","November","December"],it:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]};var ke={name:"date",active:!0,subCommand:[{name:"toIso",version:"0.0.2",example:"dphelper.date.toIso(value, 'en')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to ISO format.",env:"both",subCommand:[]},{name:"toMMDDYYYY",version:"0.0.2",example:"dphelper.date.toMMDDYYYY(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to MMDDYYYY format.",env:"both",subCommand:[]},{name:"toYYYYMMDD",version:"0.0.2",example:"dphelper.date.toYYYYMMDD(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to YYYYMMDD format.",env:"both",subCommand:[]},{name:"toHuman",version:"0.0.2",example:"dphelper.date.toHuman(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a human-readable format.",env:"both",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.date.convert(value, format)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a specified format.",env:"both",subCommand:[]},{name:"iso2Epoch",version:"0.0.2",example:"dphelper.date.iso2Epoch(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to epoch time.",env:"both",subCommand:[]},{name:"localIsoTime",version:"0.0.2",example:"dphelper.date.localIsoTime(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the local ISO time for a given date value.",env:"both",subCommand:[]},{name:"utc",version:"0.0.2",example:"dphelper.date.utc()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current UTC time.",env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.date.parse(value, '/')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Parses a date value with a specified separator.",env:"both",subCommand:[]},{name:"year",version:"0.0.2",example:"dphelper.date.year()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current year.",env:"both",subCommand:[]},{name:"addDays",version:"0.0.2",example:"dphelper.date.addDays(date, days)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Adds a specified number of days to a date.",env:"both",subCommand:[]},{name:"dateTimeToString",version:"0.0.2",example:"dphelper.date.dateTimeToString(dateObject)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date object to a string.",env:"both",subCommand:[]},{name:"isoToHuman",version:"0.0.2",example:"dphelper.date.isoToHuman(value, '@')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to a human-readable format with a specified symbol.",env:"both",subCommand:[]},{name:"fullDate",version:"0.0.2",example:"dphelper.date.fullDate()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the full date and time in the format DD-MM-YYYY HH:MM:SS.",env:"both",subCommand:[]},{name:"epoch",version:"0.0.2",example:"dphelper.date.epoch()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current epoch time.",env:"both",subCommand:[]},{name:"diffInDays",version:"0.0.2",example:"dphelper.date.diffInDays(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in days between two dates.",env:"both",subCommand:[]},{name:"diffInWeeks",version:"0.0.2",example:"dphelper.date.diffInWeeks(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in weeks between two dates.",env:"both",subCommand:[]},{name:"diffInMonths",version:"0.0.2",example:"dphelper.date.diffInMonths(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in months between two dates.",env:"both",subCommand:[]},{name:"diffInYears",version:"0.0.2",example:"dphelper.date.diffInYears(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in years between two dates.",env:"both",subCommand:[]},{name:"dateToYMD",version:"0.0.2",example:"dphelper.date.dateToYMD(date)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date to the format YYYY-MM-DD.",env:"both",subCommand:[]},{name:"collection",version:"0.0.2",example:"dphelper.date.collection()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets various date representations based on the type and locale.",env:"both",subCommand:[]},{name:"timeZones",version:"0.0.2",example:"dphelper.date.timeZones()",author:"Dario Passariello",creationDate:"20240901",lastMod:"20260220",type:"function",active:!0,description:"Returns an array of all supported timezones.",env:"both",subCommand:[]}]},Te={days:(e="en")=>({en:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],it:["luned\xEC","marted\xEC","mercoled\xEC","gioved\xEC","venerd\xEC","sabato","domenica"]})[e],months:(e="en")=>W[e],year:()=>new Date().getFullYear(),toIso:(e,t="en")=>{e||(e="");let r=new Date(e);return String(r)==="Invalid Date"?null:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"numeric"}).format(r)},toMMDDYYYY:e=>{try{let t=new Date(e);return isNaN(t.getTime())?"":`0${t.getMonth()+1}`.slice(-2)+""+`0${t.getDate()}`.slice(-2)+t.getFullYear()}catch{return""}},toYYYYMMDD:e=>{if(e)return e.toISOString().split("T")[0].replaceAll("-","")},toHuman:e=>{let t={weekday:"long",year:"numeric",month:"long",day:"numeric"};return e.toLocaleDateString(void 0,t)},convert:(e,t)=>{if(!e)return null;t||(t=dphelper.date.months("en"));let r=e.substring(0,2).replace("0",""),n=e.substring(2,4),o=e.substring(e.length-4);return`${n} ${t[Number(r)-1]} ${o}`},iso2Epoch:e=>(e||(e=""),new Date(e).getTime()),localIsoTime:e=>{e||(e=new Date);let t=new Date(e);if(isNaN(t.getTime()))return"";let r=t.getTimezoneOffset()*6e4;return new Date(Date.now()-r).toISOString().slice(0,-1)},utc:()=>new Date().toUTCString(),parse:(e,t="/")=>{if(!e)return null;let r=e.substring(0,2),n=e.substring(2,4),o=e.substring(4,8);return r+t+n+t+o},addDays:(e,t)=>{let r=new Date(Number(e));return r.setDate(e.getDate()+t),r},dateTimeToString:e=>{try{return`${e.getFullYear()}${e.getMonth().toString().length>1?e.getMonth()+1:`0${e.getMonth()+1}`}
52
+ `,env:"client",subCommand:[]},{name:"polarToCartesian",version:"0.0.2",example:"dphelper.coords.polarToCartesian([centerX, centerY, radius, angleInDegrees])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Convert polar coordinates to Cartesian coordinates",env:"client",subCommand:[]},{name:"mapDegreesToPixels",version:"0.0.2",example:"dphelper.coords.mapDegreesToPixels([degree, minDegree, maxDegree, minPixel, maxPixel, padding])",author:"Dario Passariello",creationDate:"2024-09-28",lastMod:"2024-09-28",type:"function",active:!0,description:"Map degrees to pixels",env:"client",subCommand:[]}]},L=6371e3,we={degreesToRadians:e=>e*Math.PI/180,latToMeters:e=>Array.isArray(e)?L*Math.cos(e[0])*Math.cos(e[1])/1e3:void 0,toVector:e=>{if(!Array.isArray(e))return;let t=L*Math.cos(e[1]*Math.PI/180)*Math.cos(e[0]*Math.PI/180),r=L*Math.cos(e[1]*Math.PI/180)*Math.sin(e[0]*Math.PI/180),n=L*Math.sin(e[2]*Math.PI/180);return[t,r,n]},convertToDecDegrees:(e,t,r,n)=>{let o=e+t/60+r/3600;return(n==="S"||n==="W")&&(o*=-1),o},distance:(e,t)=>{if(!(Array.isArray(e)&&Array.isArray(t)))return;let r=e[0]*Math.PI/180,n=t[0]*Math.PI/180,o=(t[0]-e[0])*Math.PI/180,a=(t[1]-e[1])*Math.PI/180,i=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(n)*Math.sin(a/2)*Math.sin(a/2),s=2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i)),l=L*s;return{km:Number((l/1e3).toFixed(2)),mi:Number((l/1e3*.621371).toFixed(2)),nMi:Number((l/1e3/1.852).toFixed(2))}},polarToCartesian:(e,t,r,n)=>{let o=(n-90)*Math.PI/180;return{x:e+r*Math.cos(o),y:t+r*Math.sin(o)}},mapDegreesToPixels:(e,t,r,n,o,a)=>{let i=(e-t)/(r-t),s=n+i*(o-n),l=a/20,d=o-(s-a)-l;return d<a?a:d}};dphelper?.setDescription(De,we);var G={contributors:[{name:"Dario Passariello",email:"dariopassariello@gmail.com"}],app:{folder:"src",type:"library",port:3e3,code:"dphelper",host:{dev:"http://localhost",prod:"https://biglogic.ca/dphelper"},socket:{url:{tst:"http://localhost:5000/",dev:"http://localhost:5000/",pro:"wss://ws.a51.dev/"}},events:{url:{tst:"http://localhost:5002/",dev:"http://localhost:5002/",pro:"wss://ws.a51.dev/"}},proxy:{api:{tst:"http://localhost:5003/",dev:"http://localhost:5003/",pro:"https://api.a51.dev/"}},url:{dev:"http://localhost/"},cdn:{}}};var Ce={name:"credits",active:!0,subCommand:[]};var Se=()=>{let e=G},Me=globalThis.dphelper;Me?.setDescription?.(Ce,Se);var W={en:["January","February","March","April","May","June","July","August","September","October","November","December"],it:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]};var ke={name:"date",active:!0,subCommand:[{name:"toIso",version:"0.0.2",example:"dphelper.date.toIso(value, 'en')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to ISO format.",env:"both",subCommand:[]},{name:"toMMDDYYYY",version:"0.0.2",example:"dphelper.date.toMMDDYYYY(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to MMDDYYYY format.",env:"both",subCommand:[]},{name:"toYYYYMMDD",version:"0.0.2",example:"dphelper.date.toYYYYMMDD(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to YYYYMMDD format.",env:"both",subCommand:[]},{name:"toHuman",version:"0.0.2",example:"dphelper.date.toHuman(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a human-readable format.",env:"both",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.date.convert(value, format)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date value to a specified format.",env:"both",subCommand:[]},{name:"iso2Epoch",version:"0.0.2",example:"dphelper.date.iso2Epoch(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to epoch time.",env:"both",subCommand:[]},{name:"localIsoTime",version:"0.0.2",example:"dphelper.date.localIsoTime(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the local ISO time for a given date value.",env:"both",subCommand:[]},{name:"utc",version:"0.0.2",example:"dphelper.date.utc()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current UTC time.",env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.date.parse(value, '/')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Parses a date value with a specified separator.",env:"both",subCommand:[]},{name:"year",version:"0.0.2",example:"dphelper.date.year()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current year.",env:"both",subCommand:[]},{name:"addDays",version:"0.0.2",example:"dphelper.date.addDays(date, days)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Adds a specified number of days to a date.",env:"both",subCommand:[]},{name:"dateTimeToString",version:"0.0.2",example:"dphelper.date.dateTimeToString(dateObject)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date object to a string.",env:"both",subCommand:[]},{name:"isoToHuman",version:"0.0.2",example:"dphelper.date.isoToHuman(value, '@')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts an ISO date value to a human-readable format with a specified symbol.",env:"both",subCommand:[]},{name:"fullDate",version:"0.0.2",example:"dphelper.date.fullDate()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the full date and time in the format DD-MM-YYYY HH:MM:SS.",env:"both",subCommand:[]},{name:"epoch",version:"0.0.2",example:"dphelper.date.epoch()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets the current epoch time.",env:"both",subCommand:[]},{name:"diffInDays",version:"0.0.2",example:"dphelper.date.diffInDays(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in days between two dates.",env:"both",subCommand:[]},{name:"diffInWeeks",version:"0.0.2",example:"dphelper.date.diffInWeeks(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in weeks between two dates.",env:"both",subCommand:[]},{name:"diffInMonths",version:"0.0.2",example:"dphelper.date.diffInMonths(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in months between two dates.",env:"both",subCommand:[]},{name:"diffInYears",version:"0.0.2",example:"dphelper.date.diffInYears(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculates the difference in years between two dates.",env:"both",subCommand:[]},{name:"dateToYMD",version:"0.0.2",example:"dphelper.date.dateToYMD(date)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Converts a date to the format YYYY-MM-DD.",env:"both",subCommand:[]},{name:"collection",version:"0.0.2",example:"dphelper.date.collection()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Gets various date representations based on the type and locale.",env:"both",subCommand:[]},{name:"timeZones",version:"0.0.2",example:"dphelper.date.timeZones()",author:"Dario Passariello",creationDate:"20240901",lastMod:"20260220",type:"function",active:!0,description:"Returns an array of all supported timezones.",env:"both",subCommand:[]}]},Te={days:(e="en")=>({en:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],it:["luned\xEC","marted\xEC","mercoled\xEC","gioved\xEC","venerd\xEC","sabato","domenica"]})[e],months:(e="en")=>W[e],year:()=>new Date().getFullYear(),toIso:(e,t="en")=>{e||(e="");let r=new Date(e);return String(r)==="Invalid Date"?null:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"numeric"}).format(r)},toMMDDYYYY:e=>{try{let t=new Date(e);return isNaN(t.getTime())?"":`0${t.getMonth()+1}`.slice(-2)+""+`0${t.getDate()}`.slice(-2)+t.getFullYear()}catch{return""}},toYYYYMMDD:e=>{if(e)return e.toISOString().split("T")[0].replaceAll("-","")},toHuman:e=>{let t={weekday:"long",year:"numeric",month:"long",day:"numeric"};return e.toLocaleDateString(void 0,t)},convert:(e,t)=>{if(!e)return null;t||(t=dphelper.date.months("en"));let r=e.substring(0,2).replace("0",""),n=e.substring(2,4),o=e.substring(e.length-4);return`${n} ${t[Number(r)-1]} ${o}`},iso2Epoch:e=>(e||(e=""),new Date(e).getTime()),localIsoTime:e=>{e||(e=new Date);let t=new Date(e);if(isNaN(t.getTime()))return"";let r=t.getTimezoneOffset()*6e4;return new Date(Date.now()-r).toISOString().slice(0,-1)},utc:()=>new Date().toUTCString(),parse:(e,t="/")=>{if(!e)return null;let r=e.substring(0,2),n=e.substring(2,4),o=e.substring(4,8);return r+t+n+t+o},addDays:(e,t)=>{let r=new Date(Number(e));return r.setDate(e.getDate()+t),r},dateTimeToString:e=>{try{return`${e.getFullYear()}${e.getMonth().toString().length>1?e.getMonth()+1:`0${e.getMonth()+1}`}
53
53
  ${e.getDate().toString().length>1?e.getDate():`0${e.getDate()}`}_${e.getHours()}${e.getMinutes()}${e.getSeconds()}`}catch{return e}},isoToHuman:(e,t="@")=>{if(!e)return null;let r=dphelper.date.months("en"),n=new Date(e),o=n.getFullYear(),a=e.split("T")[1].split(":").slice(0,2).join(":"),i=(n.getMonth()+1).toString(),s=n.getDate().toString();return s.length<2&&(s=`0${s}`),i.length<2&&(i=`0${i}`),`${s} ${r[Number(i)-1]} ${o} ${t} ${a}`},fullDate:()=>{let e=new Date,t=Number(e.getDate()),r=Number(e.getMonth()+1),n=Number(e.getFullYear()),o=Number(e.getHours()),a=Number(e.getMinutes()),i=Number(e.getSeconds());return(t<10?`0${t}`:t)+"-"+(r<10?`0${r}`:r)+"-"+n+" "+(o<10?`0${o}`:o)+":"+(a<10?`0${a}`:a)+":"+(i<10?`0${i}`:i)},epoch:()=>Date.now(),diffInDays:(e,t)=>{let r=t.getTime(),n=e.getTime();return Math.floor((r-n)/(24*3600*1e3))},diffInWeeks:(e,t)=>{let r=t.getTime(),n=e.getTime();return Number(Number.parseInt(String((r-n)/(24*3600*1e3*7)),10))},diffInMonths:(e,t)=>{let r=e.getFullYear(),n=t.getFullYear(),o=e.getMonth();return t.getMonth()+12*n-(o+12*r)},diffInYears:(e,t)=>t.getFullYear()-e.getFullYear(),dateToYMD:e=>{let t=e.getDate(),r=e.getMonth()+1;return`${e.getFullYear()}-${r<=9?`0${r}`:r}-${t<=9?`0${t}`:t}`},collection:({date:e=new Date,type:t="",locale:r="en-US"})=>{let n;switch(t){case"toDateString":n=e.toDateString();break;case"toISOString":n=e.toISOString();break;case"toJSON":n=e.toJSON();break;case"toLocaleDateString":n=e.toLocaleDateString(r);break;case"toLocaleString":n=e.toLocaleString(r);break;case"toLocaleTimeString":n=e.toLocaleTimeString(r);break;case"toString":n=e.toString();break;case"toISOStringShort":n=e.toISOString().slice(0,10);break}return n},timeZones:()=>{let e=[],t=Intl.supportedValuesOf("timeZone");for(let r of t)e.push(r);return e}};dphelper?.setDescription(ke,Te);var Ee={name:"disable",active:!0,subCommand:[{name:"select",version:"0.0.2",example:"dphelper.disable.select([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable text selection on the specified element.",env:"client",subCommand:[]},{name:"spellCheck",version:"0.0.2",example:"dphelper.disable.spellCheck([tmr = 5000])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable spell check on the specified element after a delay.",env:"client",subCommand:[]},{name:"rightClick",version:"0.0.2",example:"dphelper.disable.rightClick([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable right-click context menu on the specified element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.disable.copy([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable copy functionality on the specified element.",env:"client",subCommand:[]},{name:"paste",version:"0.0.2",example:"dphelper.disable.paste([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable paste functionality on the specified element.",env:"client",subCommand:[]},{name:"cut",version:"0.0.2",example:"dphelper.disable.cut([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable cut functionality on the specified element.",env:"client",subCommand:[]},{name:"drag",version:"0.0.2",example:"dphelper.disable.drag([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Disable drag functionality on the specified element.",env:"client",subCommand:[]}]},Ae={select:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;if(!t||typeof t.addEventListener!="function")return;let r=n=>{let o=n.target,a=o.tagName.toLowerCase();if(!["input","button","select","textarea"].includes(a)&&!o.classList.contains("selectable"))return document.querySelectorAll("*").forEach(i=>i.blur()),n.preventDefault(),!1;document.querySelectorAll("img, a, input, button").forEach(i=>{i.addEventListener("dragstart",s=>(s.preventDefault(),!1))})};t.addEventListener("mousedown",r)}catch{}},spellCheck:(e=5e3)=>{setInterval(()=>{let r=document.querySelectorAll("input[type=text], textarea, code");for(let n of r)n.getAttribute("spellcheck")||n.setAttribute("spellcheck","false")},e)},rightClick:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("contextmenu",r=>r.preventDefault())}catch{}},copy:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("copy",r=>r.preventDefault())}catch{}},paste:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("paste",r=>r.preventDefault())}catch{}},cut:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("cut",r=>r.preventDefault())}catch{}},drag:(e="body")=>{try{if(typeof document>"u")return;let t=typeof e=="string"?document.querySelector(e):e;t&&typeof t.addEventListener=="function"&&t.addEventListener("dragstart",r=>r.preventDefault())}catch{}}};dphelper?.setDescription?.(Ee,Ae);var M={},Oe={name:"dispatch",active:!0,subCommand:[{name:"set",version:"0.0.2",example:"dphelper.dispatch.set([name, value])",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:!0,description:"Dispatches a custom event with the specified name and value.",env:"client",subCommand:[]},{name:"listen",version:"0.0.2",example:"dphelper.dispatch.listen([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:!0,description:"Listens for the specified event names and executes the callback when the event is triggered.",env:"client",subCommand:[]},{name:"remove",version:"0.0.2",example:"dphelper.dispatch.remove([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:!0,description:"Removes the event listener for the specified event names.",env:"client",subCommand:[]}]},Le={set:(e,t={})=>dispatchEvent(new CustomEvent(String(e),t)),listen:(e,t)=>{M[e]&&M[e].length>0&&dphelper.dispatch.remove(e);let r=n=>t?setTimeout(()=>t(n),0):null;window.addEventListener(e,r),M[e]||(M[e]=[]),M[e].push(r)},remove:e=>{let t=M[e];t&&(t.forEach(r=>window.removeEventListener(e,r)),delete M[e])}};dphelper?.setDescription(Oe,Le);var Ne={name:"element",active:!0,subCommand:[{name:"fitScale",version:"0.0.2",example:"dphelper.element.fitScale([el = 'root', scale = 1, fit = false])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Scales an element based on the window size.",env:"client",subCommand:[]}]},je={fitScale:(e,t=1,r=!1)=>addEventListener("resize",n=>dphelper.element.scaleBasedOnWindow(e,t,r)),scaleBasedOnWindow:(e,t,r)=>{if(!e)return;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return;let o=n.offsetWidth||1,a=n.offsetHeight||1,i=r?t/Math.max(o/window.innerWidth,a/window.innerHeight):t/Math.min(o/window.innerWidth,a/window.innerHeight);n.style.transform=`scale(${i})`}};dphelper?.setDescription(Ne,je);var $e={name:"event",active:!0,subCommand:[{name:"list",version:"0.0.2",example:"dphelper.event.list([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Show attached events.",env:"client",subCommand:[]},{name:"multi",version:"0.0.2",example:"dphelper.event.multi([element, eventNames, listener])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Attach multiple event listeners to an element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.event.copy([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Copy text content of an element to the clipboard.",env:"client",subCommand:[]},{name:"onDrag",version:"0.0.2",example:"dphelper.event.onDrag([element])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Handle dragging functionality for elements.",env:"client",subCommand:[]},{name:"keys",version:"0.0.2",example:"dphelper.event.keys(e)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Return key event properties.",env:"client",subCommand:[]}]},qe={list:e=>window.getEventListeners(e),multi:(e,t,r)=>{let n=t.split(" ");for(let o of n)e.addEventListener(o,r,!1)},copy:e=>{let t=document.querySelector(e);t&&t.addEventListener("click",async r=>{if(navigator.clipboard)try{let n=r.target;n&&(await navigator.clipboard.writeText(n.textContent||""),alert("Copied"))}catch{}})},onDrag:e=>{let t=`.popup_overflow_${e}`,r=document.querySelector(t);if(!r)return;let n=o=>{let a=document.querySelector(t),i=a?.offsetHeight||0,s=a?.offsetWidth||0,l=Math.max(o.pageY,0)-i/2,d=Math.max(o.pageX,0)-s/2;localStorage.setItem(e,JSON.stringify([l,d]))};r.addEventListener("mousedown",()=>{window.addEventListener("mousemove",n)}),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",n)})},keys:e=>({key:e.key,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})};dphelper?.setDescription($e,qe);var Ie={name:"fetch",active:!0,subCommand:[{name:"get",version:"0.0.1",example:"dphelper.fetch.get('https://api.example.com')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Perform a GET request with automatic retries and exponential backoff.",env:"both",subCommand:[]},{name:"post",version:"0.0.1",example:"dphelper.fetch.post('/api', { data: 123 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:!0,description:"Perform a POST request with JSON support.",env:"both",subCommand:[]}]},j=async(e,t={},r=3,n=1e3)=>{try{let o=await globalThis.fetch(e,t);if(!o.ok&&r>0)throw new Error(o.statusText);return o}catch(o){if(r===0)throw o;return await new Promise(a=>setTimeout(a,n)),j(e,t,r-1,n*2)}},z=(e,t)=>j(e,t);z.get=(e,t)=>j(e,{...t,method:"GET"});z.post=(e,t,r={})=>{let n=typeof t=="object"&&t!==null;return j(e,{...r,method:"POST",headers:{...n?{"Content-Type":"application/json"}:{},...r.headers||{}},body:n?JSON.stringify(t):t})};dphelper?.setDescription(Ie,z);var Re={name:"form",active:!0,subCommand:[{name:"serialize",version:"0.0.2",example:"dphelper.form.serialize([form])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Serialize form data into an object.",env:"client",subCommand:[]},{name:"confirmType",version:"0.0.2",example:"dphelper.form.confirmType([type, value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Confirm the type of a value.",env:"client",subCommand:[]},{name:"required",version:"0.0.2",example:"dphelper.form.required([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value is required.",env:"client",subCommand:[]},{name:"minLength",version:"0.0.2",example:"dphelper.form.minLength([value, num = 1])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value meets the minimum length.",env:"client",subCommand:[]},{name:"maxLength",version:"0.0.2",example:"dphelper.form.maxLength([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value exceeds the maximum length.",env:"client",subCommand:[]},{name:"maxPhoneNumber",version:"0.0.2",example:"dphelper.form.maxPhoneNumber([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a phone number exceeds the maximum length.",env:"client",subCommand:[]},{name:"isNumeric",version:"0.0.2",example:"dphelper.form.isNumeric([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a value is numeric.",env:"client",subCommand:[]},{name:"isEmail",version:"0.0.2",example:"dphelper.form.isEmail([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Validate an email format.",env:"client",subCommand:[]},{name:"pattern",version:"0.0.2",example:"dphelper.form.pattern(event)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Pattern validation using onChange on inputs when you provide a pattern.",env:"client",subCommand:[]},{name:"noSpecialChars",version:"0.0.2",example:"dphelper.form.noSpecialChars(event)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:!0,description:"Avoid special characters in an input.",env:"client",subCommand:[]},{name:"table",version:"0.0.2",example:"dphelper.form.table(size = [7, 24], id, elem)",author:"Dario Passariello",creationDate:"20240101",lastMod:"20240101",type:"function",active:!0,description:"Generate a table (default 7x24).",env:"client",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.form.sanitize(input)",author:"Dario Passariello",creationDate:"20240318",lastMod:"20240318",type:"function",active:!0,description:"Sanitize input value to avoid injection.",env:"client",subCommand:[]}]},He={serialize:e=>{let t=typeof e=="string"?document.querySelector(e):e;if(!t)return{};let r={};if(!{validate:/[a-zA-Z][a-zA-Z0-9-_.]/,key:/[a-zA-Z0-9_]+|(?=\[\])/g,push:/^$/,fixed:/^\d+$/,named:/^[a-zA-Z0-9_]+$/}.validate.test(t.name))return;let o=s=>(s===""&&(s=null),s==="null"&&(s=null),s==="undefined"&&(s=void 0),s==="false"&&(s=!1),s==="true"&&(s=!0),s==="off"&&(s=!1),s==="on"&&(s=!0),s==="[]"&&(s=Array),s==="{}"&&(s=Object),["null","undefined","false","true","on","off"].filter(c=>c.includes(s)).length===0&&!Number.isNaN(s)&&(s=Number(s)),s),a=(s,l)=>{let d=s[0];d.slice(-1)==="]"&&(d=d.slice(0,-1));let c={};return s.length===1?c[d]=o(l):(s.shift(),c[d]=a(s,l)),c},i=t.serializeArray();for(let s of i){let l=s.value,d=s.name.split("["),c=a(d,l);Object.assign(r,c)}return r},confirmType:(e,t)=>e==="number"?/^\d+$/.test(t.toString()):e==="email"?/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t.toString().toLowerCase()):!0,required:e=>e==null?"Required":void 0,minLength:(e,t=1)=>!e||e.length<t?"Must Enter a Value":void 0,maxLength:(e,t=10)=>e.length>t?"Exceeds Max Length":void 0,maxPhoneNumber:(e,t=10)=>e.toString().length>t?"Exceeds Max Length":void 0,isNumeric:e=>!Number.isNaN(e),isEmail:e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e.toString().toLowerCase()),pattern:e=>{let t=e.target;if(!(t.type&&t.value))return;let r;switch(t.type){case"text":case"password":r=/^[a-zA-Z0-9.\- !$@]+$/;break;case"email":r=/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/;break;case"number":r=/^[0-9\-+]*$/;break;case"tel":r=/^[0-9\s()\-+]*$/;break;default:return}t.value.match(r)||(t.value=t.value.slice(0,-1),e.preventDefault())},noSpecialChars:e=>{let t=e.target,r=t.value.trim(),n=/[^\w\s]/gi;r.length>2&&(t.value=r.replace(n,""))},table:(e,t,r)=>{let n=e[0]||7,o=e[1]||24,a=s=>String(s).replace(/[&<>"']/g,l=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[l]||l),i=`<form id='${a(t)}'>`;i+="<div class='table'>",i+="<div class='title'>";for(let s=1;s<=n;s++)i+=`<span>${s}</span>`;i+="</div>";for(let s=1;s<=o;s++){i+=`<div class='row'><span>${s}</span>`;for(let l=1;l<=n;l++)i+=`<input name='data[${l}][${s}]' tabindex='${l.toString().padStart(2,"0")}${s.toString().padStart(2,"0")}' type='number' onclick="this.select()" value='${Math.floor(Math.random()*100)}' title='${a(l)} to ${a(s)}' />`;i+="</div>"}i+="</div>",i+="</form>",r&&(r.innerHTML=i)},sanitize:e=>{if(e)return e.replace(/[^\w ]/g,"").replace(/[&/\\#, +()$~%.'":*?<>{}]/g,"")}};dphelper?.setDescription(Re,He);var _e={name:"format",active:!0,subCommand:[{name:"currency",version:"0.0.2",example:"dphelper.format.currency(value, locale, currency)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Format a number as currency.",env:"both",subCommand:[]},{name:"phoneNumber",version:"0.0.2",example:"dphelper.format.phoneNumber(value, countryCode)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Format a string as a phone number.",env:"both",subCommand:[]}]},ze={currency:(e,t="en-US",r="USD")=>new Intl.NumberFormat(t,{style:"currency",currency:r}).format(e),phoneNumber:(e,t="US")=>{let r=`${e}`.replace(/\D/g,""),n;return t==="US"&&(n=r.match(/^(\d{3})(\d{3})(\d{4})$/),n)?`(${n[1]}) ${n[2]}-${n[3]}`:e}};dphelper?.setDescription(_e,ze);var Ue={name:"json",active:!0,subCommand:[{name:"counter",version:"0.0.2",example:"dphelper.json.counter()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Count occurrences of a key-value pair in a JSON object.",env:"both",subCommand:[]},{name:"toCsv",version:"0.0.2",example:"dphelper.json.toCsv()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Convert JSON data to CSV format.",env:"both",subCommand:[]},{name:"saveCsvAs",version:"0.0.2",example:"dphelper.json.saveCsvAs()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Save CSV data as a file.",env:"both",subCommand:[]},{name:"is",version:"0.0.2",example:"dphelper.json.is()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a string is valid JSON.",env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.json.parse()",author:"Dario Passariello",creationDate:"20241107",lastMod:"20241107",type:"function",active:!0,description:"Parse a JSON string.",env:"both",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.json.sanitize()",author:"Dario Passariello",creationDate:"20241107",lastMod:"20241107",type:"function",active:!0,description:"Sanitize a JSON string.",env:"both",subCommand:[]},{name:"sanitizeJsonValue",version:"0.0.2",example:"dphelper.json.sanitizeJsonValue()",author:"Dario Passariello",creationDate:"20241107",lastMod:"20241107",type:"function",active:!0,description:"Sanitize individual JSON values.",env:"both",subCommand:[]}]},Fe={counter:(e,t,r)=>e?t&&r?e.items&&Array.isArray(e.items)?e.items.filter(n=>n[t]===r).length:Object.keys(e).length:0:null,toCsv:e=>{let t=e,r=(a,i)=>i===null?"":i,n=Object.keys(t[0]),o=t.map(a=>n.map(i=>JSON.stringify(a[i],r)).join(","));return o.unshift(n.join(",")),o.join(`\r
54
54
  `)},saveCsvAs:(e,t)=>{let r=new Blob([e],{type:"text/csv;charset=utf-8;"}),n=document.createElement("a"),o=dphelper.date.dateTimeToString(new Date(Date.now())),a=`${t}_${o}.csv`,i=URL.createObjectURL(r);n.setAttribute("href",i),n.setAttribute("download",a),n.style.visibility="hidden",document.body.appendChild(n),n.click(),document.body.removeChild(n)},is:e=>{try{JSON.parse(e)}catch{return!1}return!0},parse:e=>{try{return JSON.parse(e)}catch{return"Json not parsable"}},sanitize:e=>e?"{"+e.trim().replace(/^\{/,"").replace(/\}$/,"").split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/).map(o=>{let[a,...i]=o.split(":"),s=dphelper.json.sanitizeJsonValue(a?.trim()??"");if(!a)return"";let l=i.join(":");return l?(l=l.trim(),l==="null"?l='""':l==="true"||l==="false"?l=`"${l}"`:/^\d+$/.test(l)?l=`"${l}"`:l=dphelper.json.sanitizeJsonValue(l)):l='""',`${s}:${l}`}).filter(o=>o!=="").join(",")+"}":"{}",sanitizeJsonValue:e=>e?`"${e.replace(/^"(.*)"$/,"$1").replace(/\\/g,"").replace(/\//g,"/").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/"/g,'\\"').replace(/\t/g," ").trim()}"`:'""'};dphelper?.setDescription(Ue,Fe);var Be={name:"load",active:!0,subCommand:[{name:"all",version:"0.0.3",example:"dphelper.load.all(import.meta.glob('./Scripts/*.ts', { eager: true }))",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260228",type:"function",active:!0,description:"Load all files from a glob object (Vite/esbuild) or require context. If you add a 'cacheName', the list is stored in cache.",env:"client",subCommand:[]},{name:"file",version:"0.0.2",example:"dphelper.load.file(filePath)",author:"Dario Passariello",creationDate:"20240101",lastMod:"20240101",type:"function",active:!0,description:"Load a specific file.",env:"client",subCommand:[]},{name:"fileToElement",version:"0.0.2",example:"dphelper.load.fileToElement(filePath, elementSelector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Load a file and insert its content into an element.",env:"client",subCommand:[]},{name:"script",version:"0.0.2",example:"dphelper.load.script(scripts, elementSelector)",author:"Dario Passariello",creationDate:"20240525",lastMod:"20240525",type:"function",active:!0,description:"Append script tags to an element.",env:"client",subCommand:[]},{name:"toJson",version:"0.0.3",example:"dphelper.load.toJson(import.meta.glob('./router/*.ts', { eager: true }), 'router')",author:"Dario Passariello",creationDate:"20250101",lastMod:"20260228",type:"function",active:!0,description:"Create JSON from folder recursion using glob object.",env:"client",subCommand:[]}]},Je={all:(e,t="")=>{if(e){if(t&&!window[t]&&(window[t]=[]),typeof e=="object"&&!e.keys){for(let r in e)t&&window[t].push(r);return}if(typeof e=="function"&&e.keys)for(let r of e.keys())t&&window[t].push(r),e(r)}},file:()=>null,fileToElement:async(e,t)=>{try{let r=await dphelper.load.file(t),n=document.querySelector(e);n&&(n.innerHTML=dphelper.sanitize.html(r))}catch{}},script:(e,t="html")=>{let r=document.querySelector(t);if(r)for(let n of e){let o=document.createElement("script");o.src=n,o.async=!0,o.defer=!0,r.appendChild(o)}},toJson:(e,t="")=>{let r={};if(e){if(t&&(r[t]=[]),typeof e=="object"&&!e.keys)for(let n in e)t&&r[t]&&r[t].push(n);else if(typeof e=="function"&&e.keys)for(let n of e.keys())t&&r[t]&&r[t].push(n),e(n);!t||!r[t]||Object.defineProperty(window,t,{value:dphelper.array.pathToJson(r[t]),writable:!1,enumerable:!1,configurable:!1})}}};dphelper?.setDescription?.(Be,Je);var Ye={name:"logging",active:!0,subCommand:[{name:"list",version:"0.0.2",example:"dphelper.log.list()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"List all log entries.",env:"both",subCommand:[]},{name:"reg",version:"0.0.2",example:"dphelper.log.reg('message')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Log a regular message.",env:"both",subCommand:[]},{name:"debug",version:"0.0.2",example:"dphelper.log.debug('message')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Log a debug message.",env:"both",subCommand:[]},{name:"error",version:"0.0.2",example:"dphelper.log.error('message')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Log an error message.",env:"both",subCommand:[]}]},v={log:[]},Ge={list:()=>v.log,reg:e=>{v.log.push({type:"reg",message:e}),v.log.length>1e3&&v.log.shift()},debug:e=>{v.log.push({type:"debug",message:e}),v.log.length>1e3&&v.log.shift()},error:e=>{v.log.push({type:"error",message:e}),v.log.length>1e3&&v.log.shift()}};Object.defineProperty(v,"log",{writable:!1,enumerable:!1,configurable:!1});dphelper?.setDescription(Ye,Ge);var We={name:"math",active:!0,subCommand:[{name:"rnd",version:"0.0.2",example:"dphelper.math.rnd()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Generate a random number.",env:"both",subCommand:[]},{name:"tmr",version:"0.0.2",example:"dphelper.math.tmr()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Measure the time taken by a function.",env:"both",subCommand:[]},{name:"isOdd",version:"0.0.2",example:"dphelper.math.isOdd(a)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a number is odd.",env:"both",subCommand:[]},{name:"percent",version:"0.0.2",example:"dphelper.math.percent([n, tot])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Calculate the percentage of a number relative to a total. Example: total: 100, number: 25 -> 25%",env:"both",subCommand:[]},{name:"isPrime",version:"0.0.2",example:"dphelper.math.isPrime(a)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,description:"Check if a number is prime.",env:"both",subCommand:[]}]},Ve={rnd:()=>Math.floor(1e5+Math.random()*dphelper.math.tmr()),tmr:()=>Math.round(dphelper.date.epoch()/1e3),isOdd:e=>Number(e)%2!==0,percent:(e,t)=>{if(t===0)throw new Error("Total cannot be zero");return Number(e)/Number(t)*100},isPrime:e=>{if(Number(e)<=1)return!1;for(let t=2;t<=Math.sqrt(Number(e));t++)if(Number(e)%t===0)return!1;return!0}};dphelper?.setDescription(We,Ve);var Ke={name:"memory",active:!0,subCommand:[{name:"lock",version:"0.0.2",example:"dphelper.memory.lock('state[key]')",author:"Dario Passariello",creationDate:"20230101",lastMod:"20230111",type:"function",active:!0,description:"Lock a state",env:"client",subCommand:[]},{name:"unlock",version:"0.0.2",example:"dphelper.memory.unlock('state[key]')",author:"Dario Passariello",creationDate:"20230101",lastMod:"20230111",type:"function",active:!0,description:"Unlock a state",env:"client",subCommand:[]}]},Ze={lock:e=>{if(!e)return;let t=window,r=e.split(".");if(r.length<2)return;let n=r[0],o=r[1];if(!n||!o)return;let a=t[n];a&&Object.defineProperty(a,o,{writable:!1,configurable:!1})},unlock:e=>{if(!e)return;let t=window,r=e.split(".");if(r.length<2)return;let n=r[0],o=r[1];if(!n||!o)return;let a=t[n];if(a)try{Object.defineProperty(a,o,{writable:!0,configurable:!0})}catch{}}};dphelper?.setDescription(Ke,Ze);var Xe={name:"navigation",active:!0,subCommand:[{name:"ajax",version:"0.0.2",example:"dphelper.navigation.ajax()",author:"Dario Passariello",creationDate:"20260223",lastMod:"20260223",type:"function",active:!0,description:"Vanilla AJAX Single Page Application (SPA) navigation engine.",env:"client",subCommand:[]},{name:"load",version:"0.0.1",example:"dphelper.navigation.load('/home')",author:"Dario Passariello",creationDate:"20260223",lastMod:"20260223",type:"function",active:!0,description:"Loads a page via AJAX and injects it into the body.",env:"client",subCommand:[]}]},Qe={load:async e=>{let r=document.body,n=e.startsWith("/")?e.split("/")[1]||"home":e;if((!n||n==="")&&(n="home"),!document.querySelector(".loader")){let o=document.createElement("div");o.className="loader",o.innerHTML="<i></i>",o.style.opacity="0",o.style.transition="opacity 1000ms",r.appendChild(o),setTimeout(()=>o.style.opacity="1",10)}try{let o=await fetch(`${n}/`);if(!o.ok)throw new Error("Page not found");let a=await o.text(),i=a.match(/<body[^>]*>([\s\S]*)<\/body>/i),s=i?i[1]:a,l=p=>{let m=document.createElement("div");return m.textContent=p,m.innerHTML},d=dphelper?.sanitize?.html?dphelper.sanitize.html(s||""):l(s||"");r.innerHTML=d,window.scrollTo({top:0,behavior:"smooth"}),document.title=n.charAt(0).toUpperCase()+n.slice(1);let c=dphelper.path.rail();c&&c.length>0&&(r.className=r.className.replace(/path-\w+/g,"").trim(),r.classList.add(`path-${c[c.length-1]}`)),globalThis.dphelper.navigation.ajax_running&&dphelper.navigation.ajax()}catch{let a=window.location.origin;e.startsWith("/")&&!e.startsWith("//")&&!e.match(/^[a-zA-Z]:/)&&new URL(e,a).href.startsWith(a)&&(window.location.href=e)}},_bind:e=>{document.querySelectorAll(e).forEach(r=>{let n=r.getAttribute("href");if(!n||!n.startsWith("/")||n.includes("#"))return;let o=r.cloneNode(!0);r.parentNode?.replaceChild(o,r),o.addEventListener("mouseup",a=>{let i=o.getAttribute("data-href")||n;history.pushState({href:i},"",i),dphelper.navigation.load(i),o.removeAttribute("href"),a.stopPropagation()})})},ajax:()=>{if(globalThis.dphelper.navigation.ajax_running){dphelper.navigation._bind("a");return}globalThis.dphelper.navigation.ajax_running=!0,window.onpopstate=()=>dphelper.navigation.load(window.location.pathname),dphelper.navigation._bind("a"),globalThis.dp_hash_listener_set||(window.addEventListener("hashchange",()=>{let e=window.location.hash.substring(1);e&&document.getElementById(e)?.scrollIntoView({behavior:"smooth"})}),globalThis.dp_hash_listener_set=!0)}};dphelper?.setDescription(Xe,Qe);var et={name:"obj",active:!0,subCommand:[{name:"replaceNullObjects",version:"0.0.2",example:"dphelper.obj.replaceNullObjects([obj])",description:"Replace null values in an object with empty objects.",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,env:"both",subCommand:[]},{name:"serialize",version:"0.0.2",example:"dphelper.obj.serialize([obj])",description:"Serialize an object to a JSON string.",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,env:"both",subCommand:[]},{name:"deSerialize",version:"0.0.2",example:"dphelper.obj.deSerialize([obj])",description:"Deserialize a JSON string to an object.",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:!0,env:"both",subCommand:[]},{name:"toXML",version:"0.0.2",example:"dphelper.obj.toXML([obj])",description:"Convert an object to an XML string.",author:"Dario Passariello",creationDate:"20240315",lastMod:"20240315",type:"function",active:!0,env:"both",subCommand:[]},{name:"updateByKey",version:"0.0.2",example:"dphelper.obj.updateByKey([obj, key, newValue])",description:"Update an object's property by key.",author:"Dario Passariello",creationDate:"20240929",lastMod:"20240929",type:"function",active:!0,env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.obj.parse(val)",description:"Check if value is an object or another type. Return object after parse or a different type. Used instead of JSON.parse to avoid crash.",author:"Dario Passariello",creationDate:"20241027",lastMod:"20240927",type:"function",active:!0,env:"both",subCommand:[]},{name:"diff",version:"0.0.2",example:"dphelper.obj.diff([obj1, obj2])",description:"Show the differences between two objects.",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",type:"function",active:!0,env:"both",subCommand:[]},{name:"setProps",version:"0.0.2",example:"dphelper.obj.setProps( [object], {options} )",author:"Dario Passariello",creationDate:"20251224",lastMod:"20251224",type:"function",active:!0,description:"Set properties of an object.",env:"both",subCommand:[]}]},tt={replaceNullObjects:e=>{let t={...e};for(let r of Object.keys(e))t[r]===null&&(t[r]="")},serialize:e=>{if(typeof e=="function")return e.toString();if(typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=dphelper.obj.serialize(n);return t}return e},deSerialize:e=>{if(typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=dphelper.obj.deSerialize(n);return t}return e},sort:e=>Object.keys(e).sort().reduce((t,r)=>(t[r]=e[r],t),{}),toXML:e=>{let t=(r,n="")=>{let o="";for(let a in r)if(Object.hasOwn(r,a)){let i=r[a];typeof i=="object"&&i!==null?o+=`${n}<${a}>
55
55
  ${t(i,`${n} `)}${n}</${a}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dphelper",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "dphelper devtools for developers",
5
5
  "type": "module",
6
6
  "main": "./index.js",