easy-forms-core 1.3.2 → 1.3.3
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/dist/easy-form.d.ts +2 -2
- package/dist/easy-form.js +179 -60
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +133 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var at=Object.defineProperty;var jt=(o,t,e)=>t in o?at(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var Wt=(o,t)=>()=>(o&&(t=o(o=0)),t);var Ut=(o,t)=>{for(var e in t)at(o,e,{get:t[e],enumerable:!0})};var T=(o,t,e)=>jt(o,typeof t!="symbol"?t+"":t,e);var Je={};Ut(Je,{Hooks:()=>
|
|
1
|
+
var at=Object.defineProperty;var jt=(o,t,e)=>t in o?at(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var Wt=(o,t)=>()=>(o&&(t=o(o=0)),t);var Ut=(o,t)=>{for(var e in t)at(o,e,{get:t[e],enumerable:!0})};var T=(o,t,e)=>jt(o,typeof t!="symbol"?t+"":t,e);var Je={};Ut(Je,{Hooks:()=>_,Lexer:()=>M,Marked:()=>Bt,Parser:()=>z,Renderer:()=>X,TextRenderer:()=>ze,Tokenizer:()=>J,defaults:()=>R,getDefaults:()=>Te,lexer:()=>Gr,marked:()=>C,options:()=>_r,parse:()=>Yr,parseInline:()=>Ur,parser:()=>Zr,setOptions:()=>Or,use:()=>jr,walkTokens:()=>Wr});function Te(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function Mt(o){R=o}function E(o,t=""){let e=typeof o=="string"?o:o.source,a={replace:(r,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(L.caret,"$1"),e=e.replace(r,i),a},getRegex:()=>new RegExp(e,t)};return a}function A(o,t){if(t){if(L.escapeTest.test(o))return o.replace(L.escapeReplace,Ct)}else if(L.escapeTestNoEncode.test(o))return o.replace(L.escapeReplaceNoEncode,Ct);return o}function Ft(o){try{o=encodeURI(o).replace(L.percentDecode,"%")}catch{return null}return o}function Tt(o,t){let e=o.replace(L.findPipe,(s,i,l)=>{let n=!1,d=i;for(;--d>=0&&l[d]==="\\";)n=!n;return n?"|":" |"}),a=e.split(L.splitPipe),r=0;if(a[0].trim()||a.shift(),a.length>0&&!a.at(-1)?.trim()&&a.pop(),t)if(a.length>t)a.splice(t);else for(;a.length<t;)a.push("");for(;r<a.length;r++)a[r]=a[r].trim().replace(L.slashPipe,"|");return a}function Q(o,t,e){let a=o.length;if(a===0)return"";let r=0;for(;r<a;){let s=o.charAt(a-r-1);if(s===t&&!e)r++;else if(s!==t&&e)r++;else break}return o.slice(0,a-r)}function Vr(o,t){if(o.indexOf(t[1])===-1)return-1;let e=0;for(let a=0;a<o.length;a++)if(o[a]==="\\")a++;else if(o[a]===t[0])e++;else if(o[a]===t[1]&&(e--,e<0))return a;return e>0?-2:-1}function Hr(o,t=0){let e=t,a="";for(let r of o)if(r===" "){let s=4-e%4;a+=" ".repeat(s),e+=s}else a+=r,e++;return a}function Lt(o,t,e,a,r){let s=t.href,i=t.title||null,l=o[1].replace(r.other.outputLinkReplace,"$1");a.state.inLink=!0;let n={type:o[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:i,text:l,tokens:a.inlineTokens(l)};return a.state.inLink=!1,n}function Br(o,t,e){let a=o.match(e.other.indentCodeCompensation);if(a===null)return t;let r=a[1];return t.split(`
|
|
2
2
|
`).map(s=>{let i=s.match(e.other.beginningSpace);if(i===null)return s;let[l]=i;return l.length>=r.length?s.slice(r.length):s}).join(`
|
|
3
|
-
`)}function C(o,t){return V.parse(o,t)}var R,D,er,L,tr,rr,ar,ee,sr,We,zt,
|
|
4
|
-
]`).replace("lheading",
|
|
3
|
+
`)}function C(o,t){return V.parse(o,t)}var R,D,er,L,tr,rr,ar,ee,sr,We,zt,At,ir,Ue,or,Ye,nr,lr,Le,Ze,dr,It,cr,Ge,St,pr,mr,ur,fr,Rt,hr,Me,Ke,$t,gr,qt,br,yr,Pt,vr,xr,kr,Nt,wr,Sr,Dt,Er,Cr,Fr,Tr,Lr,Mr,zr,Ar,Ir,Rr,Fe,$r,Vt,Ht,qr,Et,Qe,Pr,_e,Nr,Ee,K,Dr,Ct,J,M,X,ze,z,Ce,_,Bt,V,_r,Or,jr,Wr,Ur,Yr,Zr,Gr,Xe=Wt(()=>{"use strict";R=Te();D={exec:()=>null};er=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),L={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:o=>new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}#`),htmlBeginRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}>`)},tr=/^(?:[ \t]*(?:\n|$))+/,rr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ar=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ee=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,We=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,zt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,At=E(zt).replace(/bull/g,We).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ir=E(zt).replace(/bull/g,We).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ue=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,or=/^[^\n]+/,Ye=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,nr=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ye).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),lr=E(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,We).getRegex(),Le="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ze=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,dr=E("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ze).replace("tag",Le).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),It=E(Ue).replace("hr",ee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex(),cr=E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",It).getRegex(),Ge={blockquote:cr,code:rr,def:nr,fences:ar,heading:sr,hr:ee,html:dr,lheading:At,list:lr,newline:tr,paragraph:It,table:D,text:or},St=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex(),pr={...Ge,lheading:ir,table:St,paragraph:E(Ue).replace("hr",ee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",St).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex()},mr={...Ge,html:E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ze).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:D,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(Ue).replace("hr",ee).replace("heading",` *#{1,6} *[^
|
|
4
|
+
]`).replace("lheading",At).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ur=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,fr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Rt=/^( {2,}|\\)\n(?!\s*$)/,hr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Me=/[\p{P}\p{S}]/u,Ke=/[\s\p{P}\p{S}]/u,$t=/[^\s\p{P}\p{S}]/u,gr=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ke).getRegex(),qt=/(?!~)[\p{P}\p{S}]/u,br=/(?!~)[\s\p{P}\p{S}]/u,yr=/(?:[^\s\p{P}\p{S}]|~)/u,Pt=/(?![*_])[\p{P}\p{S}]/u,vr=/(?![*_])[\s\p{P}\p{S}]/u,xr=/(?:[^\s\p{P}\p{S}]|[*_])/u,kr=E(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",er?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Nt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,wr=E(Nt,"u").replace(/punct/g,Me).getRegex(),Sr=E(Nt,"u").replace(/punct/g,qt).getRegex(),Dt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Er=E(Dt,"gu").replace(/notPunctSpace/g,$t).replace(/punctSpace/g,Ke).replace(/punct/g,Me).getRegex(),Cr=E(Dt,"gu").replace(/notPunctSpace/g,yr).replace(/punctSpace/g,br).replace(/punct/g,qt).getRegex(),Fr=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,$t).replace(/punctSpace/g,Ke).replace(/punct/g,Me).getRegex(),Tr=E(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Pt).getRegex(),Lr="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Mr=E(Lr,"gu").replace(/notPunctSpace/g,xr).replace(/punctSpace/g,vr).replace(/punct/g,Pt).getRegex(),zr=E(/\\(punct)/,"gu").replace(/punct/g,Me).getRegex(),Ar=E(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ir=E(Ze).replace("(?:-->|$)","-->").getRegex(),Rr=E("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ir).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Fe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,$r=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Fe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Vt=E(/^!?\[(label)\]\[(ref)\]/).replace("label",Fe).replace("ref",Ye).getRegex(),Ht=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ye).getRegex(),qr=E("reflink|nolink(?!\\()","g").replace("reflink",Vt).replace("nolink",Ht).getRegex(),Et=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Qe={_backpedal:D,anyPunctuation:zr,autolink:Ar,blockSkip:kr,br:Rt,code:fr,del:D,delLDelim:D,delRDelim:D,emStrongLDelim:wr,emStrongRDelimAst:Er,emStrongRDelimUnd:Fr,escape:ur,link:$r,nolink:Ht,punctuation:gr,reflink:Vt,reflinkSearch:qr,tag:Rr,text:hr,url:D},Pr={...Qe,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",Fe).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Fe).getRegex()},_e={...Qe,emStrongRDelimAst:Cr,emStrongLDelim:Sr,delLDelim:Tr,delRDelim:Mr,url:E(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Et).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:E(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Et).getRegex()},Nr={..._e,br:E(Rt).replace("{2,}","*").getRegex(),text:E(_e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ee={normal:Ge,gfm:pr,pedantic:mr},K={normal:Qe,gfm:_e,breaks:Nr,pedantic:Pr},Dr={"&":"&","<":"<",">":">",'"':""","'":"'"},Ct=o=>Dr[o];J=class{constructor(o){T(this,"options");T(this,"rules");T(this,"lexer");this.options=o||R}space(o){let t=this.rules.block.newline.exec(o);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(o){let t=this.rules.block.code.exec(o);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Q(e,`
|
|
5
5
|
`)}}}fences(o){let t=this.rules.block.fences.exec(o);if(t){let e=t[0],a=Br(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:a}}}heading(o){let t=this.rules.block.heading.exec(o);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let a=Q(e,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(e=a.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(o){let t=this.rules.block.hr.exec(o);if(t)return{type:"hr",raw:Q(t[0],`
|
|
6
6
|
`)}}blockquote(o){let t=this.rules.block.blockquote.exec(o);if(t){let e=Q(t[0],`
|
|
7
7
|
`).split(`
|
|
@@ -17,13 +17,13 @@ ${c}`:c;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
17
17
|
`);continue}}return{type:"blockquote",raw:a,tokens:s,text:r}}}list(o){let t=this.rules.block.list.exec(o);if(t){let e=t[1].trim(),a=e.length>1,r={type:"list",raw:"",ordered:a,start:a?+e.slice(0,-1):"",loose:!1,items:[]};e=a?`\\d{1,9}\\${e.slice(-1)}`:`\\${e}`,this.options.pedantic&&(e=a?e:"[*+-]");let s=this.rules.other.listItemRegex(e),i=!1;for(;o;){let n=!1,d="",c="";if(!(t=s.exec(o))||this.rules.block.hr.test(o))break;d=t[0],o=o.substring(d.length);let m=Hr(t[2].split(`
|
|
18
18
|
`,1)[0],t[1].length),p=o.split(`
|
|
19
19
|
`,1)[0],u=!m.trim(),h=0;if(this.options.pedantic?(h=2,c=m.trimStart()):u?h=t[1].length+1:(h=m.search(this.rules.other.nonSpaceChar),h=h>4?1:h,c=m.slice(h),h+=t[1].length),u&&this.rules.other.blankLine.test(p)&&(d+=p+`
|
|
20
|
-
`,o=o.substring(p.length+1),n=!0),!n){let g=this.rules.other.nextBulletRegex(h),f=this.rules.other.hrRegex(h),y=this.rules.other.fencesBeginRegex(h),
|
|
21
|
-
`,1)[0],k;if(p=S,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),k=p):k=p.replace(this.rules.other.tabCharGlobal," "),y.test(p)||
|
|
22
|
-
`+k.slice(h);else{if(u||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(m)||
|
|
20
|
+
`,o=o.substring(p.length+1),n=!0),!n){let g=this.rules.other.nextBulletRegex(h),f=this.rules.other.hrRegex(h),y=this.rules.other.fencesBeginRegex(h),v=this.rules.other.headingBeginRegex(h),b=this.rules.other.htmlBeginRegex(h),w=this.rules.other.blockquoteBeginRegex(h);for(;o;){let S=o.split(`
|
|
21
|
+
`,1)[0],k;if(p=S,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),k=p):k=p.replace(this.rules.other.tabCharGlobal," "),y.test(p)||v.test(p)||b.test(p)||w.test(p)||g.test(p)||f.test(p))break;if(k.search(this.rules.other.nonSpaceChar)>=h||!p.trim())c+=`
|
|
22
|
+
`+k.slice(h);else{if(u||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(m)||v.test(m)||f.test(m))break;c+=`
|
|
23
23
|
`+p}u=!p.trim(),d+=S+`
|
|
24
24
|
`,o=o.substring(S.length+1),m=k.slice(h)}}r.loose||(i?r.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(i=!0)),r.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),r.raw+=d}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let n of r.items){if(this.lexer.state.top=!1,n.tokens=this.lexer.blockTokens(n.text,[]),n.task){if(n.text=n.text.replace(this.rules.other.listReplaceTask,""),n.tokens[0]?.type==="text"||n.tokens[0]?.type==="paragraph"){n.tokens[0].raw=n.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),n.tokens[0].text=n.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(n.raw);if(d){let c={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};n.checked=c.checked,r.loose?n.tokens[0]&&["paragraph","text"].includes(n.tokens[0].type)&&"tokens"in n.tokens[0]&&n.tokens[0].tokens?(n.tokens[0].raw=c.raw+n.tokens[0].raw,n.tokens[0].text=c.raw+n.tokens[0].text,n.tokens[0].tokens.unshift(c)):n.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):n.tokens.unshift(c)}}if(!r.loose){let d=n.tokens.filter(m=>m.type==="space"),c=d.length>0&&d.some(m=>this.rules.other.anyLine.test(m.raw));r.loose=c}}if(r.loose)for(let n of r.items){n.loose=!0;for(let d of n.tokens)d.type==="text"&&(d.type="paragraph")}return r}}html(o){let t=this.rules.block.html.exec(o);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(o){let t=this.rules.block.def.exec(o);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:a,title:r}}}table(o){let t=this.rules.block.table.exec(o);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=Tt(t[1]),a=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
25
|
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===a.length){for(let i of a)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<e.length;i++)s.header.push({text:e[i],tokens:this.lexer.inline(e[i]),header:!0,align:s.align[i]});for(let i of r)s.rows.push(Tt(i,s.header.length).map((l,n)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[n]})));return s}}lheading(o){let t=this.rules.block.lheading.exec(o);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(o){let t=this.rules.block.paragraph.exec(o);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
26
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(o){let t=this.rules.block.text.exec(o);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(o){let t=this.rules.inline.escape.exec(o);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(o){let t=this.rules.inline.tag.exec(o);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(o){let t=this.rules.inline.link.exec(o);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=Q(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=Vr(t[2],"()");if(s===-2)return;if(s>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let a=t[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(a);s&&(a=s[1],r=s[3])}else r=t[3]?t[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?a=a.slice(1):a=a.slice(1,-1)),Lt(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(o,t){let e;if((e=this.rules.inline.reflink.exec(o))||(e=this.rules.inline.nolink.exec(o))){let a=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[a.toLowerCase()];if(!r){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Lt(e,r,e[0],this.lexer,this.rules)}}emStrong(o,t,e=""){let a=this.rules.inline.emStrongLDelim.exec(o);if(!(!a||a[3]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(a[1]||a[2])||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,l=r,n=0,d=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*o.length+r);(a=d.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s)continue;if(i=[...s].length,a[3]||a[4]){l+=i;continue}else if((a[5]||a[6])&&r%3&&!((r+i)%3)){n+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+n);let c=[...a[0]][0].length,m=o.slice(0,r+a.index+c+i);if(Math.min(r,i)%2){let u=m.slice(1,-1);return{type:"em",raw:m,text:u,tokens:this.lexer.inlineTokens(u)}}let p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(o){let t=this.rules.inline.code.exec(o);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),a=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return a&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(o){let t=this.rules.inline.br.exec(o);if(t)return{type:"br",raw:t[0]}}del(o,t,e=""){let a=this.rules.inline.delLDelim.exec(o);if(a&&(!a[1]||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,l=r,n=this.rules.inline.delRDelim;for(n.lastIndex=0,t=t.slice(-1*o.length+r);(a=n.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s||(i=[...s].length,i!==r))continue;if(a[3]||a[4]){l+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l);let d=[...a[0]][0].length,c=o.slice(0,r+a.index+d+i),m=c.slice(r,-r);return{type:"del",raw:c,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(o){let t=this.rules.inline.autolink.exec(o);if(t){let e,a;return t[2]==="@"?(e=t[1],a="mailto:"+e):(e=t[1],a=e),{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}url(o){let t;if(t=this.rules.inline.url.exec(o)){let e,a;if(t[2]==="@")e=t[0],a="mailto:"+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);e=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(o){let t=this.rules.inline.text.exec(o);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},
|
|
26
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(o){let t=this.rules.block.text.exec(o);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(o){let t=this.rules.inline.escape.exec(o);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(o){let t=this.rules.inline.tag.exec(o);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(o){let t=this.rules.inline.link.exec(o);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=Q(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=Vr(t[2],"()");if(s===-2)return;if(s>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let a=t[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(a);s&&(a=s[1],r=s[3])}else r=t[3]?t[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?a=a.slice(1):a=a.slice(1,-1)),Lt(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(o,t){let e;if((e=this.rules.inline.reflink.exec(o))||(e=this.rules.inline.nolink.exec(o))){let a=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[a.toLowerCase()];if(!r){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Lt(e,r,e[0],this.lexer,this.rules)}}emStrong(o,t,e=""){let a=this.rules.inline.emStrongLDelim.exec(o);if(!(!a||a[3]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(a[1]||a[2])||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,l=r,n=0,d=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*o.length+r);(a=d.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s)continue;if(i=[...s].length,a[3]||a[4]){l+=i;continue}else if((a[5]||a[6])&&r%3&&!((r+i)%3)){n+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+n);let c=[...a[0]][0].length,m=o.slice(0,r+a.index+c+i);if(Math.min(r,i)%2){let u=m.slice(1,-1);return{type:"em",raw:m,text:u,tokens:this.lexer.inlineTokens(u)}}let p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(o){let t=this.rules.inline.code.exec(o);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),a=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return a&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(o){let t=this.rules.inline.br.exec(o);if(t)return{type:"br",raw:t[0]}}del(o,t,e=""){let a=this.rules.inline.delLDelim.exec(o);if(a&&(!a[1]||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,l=r,n=this.rules.inline.delRDelim;for(n.lastIndex=0,t=t.slice(-1*o.length+r);(a=n.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s||(i=[...s].length,i!==r))continue;if(a[3]||a[4]){l+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l);let d=[...a[0]][0].length,c=o.slice(0,r+a.index+d+i),m=c.slice(r,-r);return{type:"del",raw:c,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(o){let t=this.rules.inline.autolink.exec(o);if(t){let e,a;return t[2]==="@"?(e=t[1],a="mailto:"+e):(e=t[1],a=e),{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}url(o){let t;if(t=this.rules.inline.url.exec(o)){let e,a;if(t[2]==="@")e=t[0],a="mailto:"+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);e=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(o){let t=this.rules.inline.text.exec(o);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},M=class Oe{constructor(t){T(this,"tokens");T(this,"options");T(this,"state");T(this,"inlineQueue");T(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||R,this.options.tokenizer=this.options.tokenizer||new J,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:L,block:Ee.normal,inline:K.normal};this.options.pedantic?(e.block=Ee.pedantic,e.inline=K.pedantic):this.options.gfm&&(e.block=Ee.gfm,this.options.breaks?e.inline=K.breaks:e.inline=K.gfm),this.tokenizer.rules=e}static get rules(){return{block:Ee,inline:K}}static lex(t,e){return new Oe(e).lex(t)}static lexInline(t,e){return new Oe(e).inlineTokens(t)}lex(t){t=t.replace(L.carriageReturn,`
|
|
27
27
|
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let a=this.inlineQueue[e];this.inlineTokens(a.src,a.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],a=!1){for(this.options.pedantic&&(t=t.replace(L.tabCharGlobal," ").replace(L.spaceLine,""));t;){let r;if(this.options.extensions?.block?.some(i=>(r=i.call({lexer:this},t,e))?(t=t.substring(r.raw.length),e.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let i=e.at(-1);r.raw.length===1&&i!==void 0?i.raw+=`
|
|
28
28
|
`:e.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let i=e.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
29
29
|
`)?"":`
|
|
@@ -38,8 +38,8 @@ ${c}`:c;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
38
38
|
`)?"":`
|
|
39
39
|
`)+r.raw,i.text+=`
|
|
40
40
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):e.push(r);continue}if(t){let i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let a=t,r=null;if(this.tokens.links){let n=Object.keys(this.tokens.links);if(n.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)n.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,r.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)s=r[2]?r[2].length:0,a=a.slice(0,r.index+s)+"["+"a".repeat(r[0].length-s-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);a=this.options.hooks?.emStrongMask?.call({lexer:this},a)??a;let i=!1,l="";for(;t;){i||(l=""),i=!1;let n;if(this.options.extensions?.inline?.some(c=>(n=c.call({lexer:this},t,e))?(t=t.substring(n.raw.length),e.push(n),!0):!1))continue;if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length);let c=e.at(-1);n.type==="text"&&c?.type==="text"?(c.raw+=n.raw,c.text+=n.text):e.push(n);continue}if(n=this.tokenizer.emStrong(t,a,l)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.del(t,a,l)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),e.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),e.push(n);continue}let d=t;if(this.options.extensions?.startInline){let c=1/0,m=t.slice(1),p;this.options.extensions.startInline.forEach(u=>{p=u.call({lexer:this},m),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(d=t.substring(0,c+1))}if(n=this.tokenizer.inlineText(d)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(l=n.raw.slice(-1)),i=!0;let c=e.at(-1);c?.type==="text"?(c.raw+=n.raw,c.text+=n.text):e.push(n);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return e}},X=class{constructor(o){T(this,"options");T(this,"parser");this.options=o||R}space(o){return""}code({text:o,lang:t,escaped:e}){let a=(t||"").match(L.notSpaceStart)?.[0],r=o.replace(L.endingNewline,"")+`
|
|
41
|
-
`;return a?'<pre><code class="language-'+
|
|
42
|
-
`:"<pre><code>"+(e?r:
|
|
41
|
+
`;return a?'<pre><code class="language-'+A(a)+'">'+(e?r:A(r,!0))+`</code></pre>
|
|
42
|
+
`:"<pre><code>"+(e?r:A(r,!0))+`</code></pre>
|
|
43
43
|
`}blockquote({tokens:o}){return`<blockquote>
|
|
44
44
|
${this.parser.parse(o)}</blockquote>
|
|
45
45
|
`}html({text:o}){return o}def(o){return""}heading({tokens:o,depth:t}){return`<h${t}>${this.parser.parseInline(o)}</h${t}>
|
|
@@ -55,8 +55,8 @@ ${this.parser.parse(o)}</blockquote>
|
|
|
55
55
|
`}tablerow({text:o}){return`<tr>
|
|
56
56
|
${o}</tr>
|
|
57
57
|
`}tablecell(o){let t=this.parser.parseInline(o.tokens),e=o.header?"th":"td";return(o.align?`<${e} align="${o.align}">`:`<${e}>`)+t+`</${e}>
|
|
58
|
-
`}strong({tokens:o}){return`<strong>${this.parser.parseInline(o)}</strong>`}em({tokens:o}){return`<em>${this.parser.parseInline(o)}</em>`}codespan({text:o}){return`<code>${
|
|
59
|
-
Please report this to https://github.com/markedjs/marked.`,o){let a="<p>An error occurred:</p><pre>"+
|
|
58
|
+
`}strong({tokens:o}){return`<strong>${this.parser.parseInline(o)}</strong>`}em({tokens:o}){return`<em>${this.parser.parseInline(o)}</em>`}codespan({text:o}){return`<code>${A(o,!0)}</code>`}br(o){return"<br>"}del({tokens:o}){return`<del>${this.parser.parseInline(o)}</del>`}link({href:o,title:t,tokens:e}){let a=this.parser.parseInline(e),r=Ft(o);if(r===null)return a;o=r;let s='<a href="'+o+'"';return t&&(s+=' title="'+A(t)+'"'),s+=">"+a+"</a>",s}image({href:o,title:t,text:e,tokens:a}){a&&(e=this.parser.parseInline(a,this.parser.textRenderer));let r=Ft(o);if(r===null)return A(e);o=r;let s=`<img src="${o}" alt="${A(e)}"`;return t&&(s+=` title="${A(t)}"`),s+=">",s}text(o){return"tokens"in o&&o.tokens?this.parser.parseInline(o.tokens):"escaped"in o&&o.escaped?o.text:A(o.text)}},ze=class{strong({text:o}){return o}em({text:o}){return o}codespan({text:o}){return o}del({text:o}){return o}html({text:o}){return o}text({text:o}){return o}link({text:o}){return""+o}image({text:o}){return""+o}br(){return""}checkbox({raw:o}){return o}},z=class je{constructor(t){T(this,"options");T(this,"renderer");T(this,"textRenderer");this.options=t||R,this.options.renderer=this.options.renderer||new X,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ze}static parse(t,e){return new je(e).parse(t)}static parseInline(t,e){return new je(e).parseInline(t)}parse(t){let e="";for(let a=0;a<t.length;a++){let r=t[a];if(this.options.extensions?.renderers?.[r.type]){let i=r,l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){e+=l||"";continue}}let s=r;switch(s.type){case"space":{e+=this.renderer.space(s);break}case"hr":{e+=this.renderer.hr(s);break}case"heading":{e+=this.renderer.heading(s);break}case"code":{e+=this.renderer.code(s);break}case"table":{e+=this.renderer.table(s);break}case"blockquote":{e+=this.renderer.blockquote(s);break}case"list":{e+=this.renderer.list(s);break}case"checkbox":{e+=this.renderer.checkbox(s);break}case"html":{e+=this.renderer.html(s);break}case"def":{e+=this.renderer.def(s);break}case"paragraph":{e+=this.renderer.paragraph(s);break}case"text":{e+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return e}parseInline(t,e=this.renderer){let a="";for(let r=0;r<t.length;r++){let s=t[r];if(this.options.extensions?.renderers?.[s.type]){let l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){a+=l||"";continue}}let i=s;switch(i.type){case"escape":{a+=e.text(i);break}case"html":{a+=e.html(i);break}case"link":{a+=e.link(i);break}case"image":{a+=e.image(i);break}case"checkbox":{a+=e.checkbox(i);break}case"strong":{a+=e.strong(i);break}case"em":{a+=e.em(i);break}case"codespan":{a+=e.codespan(i);break}case"br":{a+=e.br(i);break}case"del":{a+=e.del(i);break}case"text":{a+=e.text(i);break}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return a}},_=(Ce=class{constructor(o){T(this,"options");T(this,"block");this.options=o||R}preprocess(o){return o}postprocess(o){return o}processAllTokens(o){return o}emStrongMask(o){return o}provideLexer(){return this.block?M.lex:M.lexInline}provideParser(){return this.block?z.parse:z.parseInline}},T(Ce,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),T(Ce,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ce),Bt=class{constructor(...o){T(this,"defaults",Te());T(this,"options",this.setOptions);T(this,"parse",this.parseMarkdown(!0));T(this,"parseInline",this.parseMarkdown(!1));T(this,"Parser",z);T(this,"Renderer",X);T(this,"TextRenderer",ze);T(this,"Lexer",M);T(this,"Tokenizer",J);T(this,"Hooks",_);this.use(...o)}walkTokens(o,t){let e=[];for(let a of o)switch(e=e.concat(t.call(this,a)),a.type){case"table":{let r=a;for(let s of r.header)e=e.concat(this.walkTokens(s.tokens,t));for(let s of r.rows)for(let i of s)e=e.concat(this.walkTokens(i.tokens,t));break}case"list":{let r=a;e=e.concat(this.walkTokens(r.items,t));break}default:{let r=a;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(s=>{let i=r[s].flat(1/0);e=e.concat(this.walkTokens(i,t))}):r.tokens&&(e=e.concat(this.walkTokens(r.tokens,t)))}}return e}use(...o){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return o.forEach(e=>{let a={...e};if(a.async=this.defaults.async||a.async||!1,e.extensions&&(e.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let s=t.renderers[r.name];s?t.renderers[r.name]=function(...i){let l=r.renderer.apply(this,i);return l===!1&&(l=s.apply(this,i)),l}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[r.level];s?s.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),a.extensions=t),e.renderer){let r=this.defaults.renderer||new X(this.defaults);for(let s in e.renderer){if(!(s in r))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,l=e.renderer[i],n=r[i];r[i]=(...d)=>{let c=l.apply(r,d);return c===!1&&(c=n.apply(r,d)),c||""}}a.renderer=r}if(e.tokenizer){let r=this.defaults.tokenizer||new J(this.defaults);for(let s in e.tokenizer){if(!(s in r))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,l=e.tokenizer[i],n=r[i];r[i]=(...d)=>{let c=l.apply(r,d);return c===!1&&(c=n.apply(r,d)),c}}a.tokenizer=r}if(e.hooks){let r=this.defaults.hooks||new _;for(let s in e.hooks){if(!(s in r))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,l=e.hooks[i],n=r[i];_.passThroughHooks.has(s)?r[i]=d=>{if(this.defaults.async&&_.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await l.call(r,d);return n.call(r,m)})();let c=l.call(r,d);return n.call(r,c)}:r[i]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await l.apply(r,d);return m===!1&&(m=await n.apply(r,d)),m})();let c=l.apply(r,d);return c===!1&&(c=n.apply(r,d)),c}}a.hooks=r}if(e.walkTokens){let r=this.defaults.walkTokens,s=e.walkTokens;a.walkTokens=function(i){let l=[];return l.push(s.call(this,i)),r&&(l=l.concat(r.call(this,i))),l}}this.defaults={...this.defaults,...a}}),this}setOptions(o){return this.defaults={...this.defaults,...o},this}lexer(o,t){return M.lex(o,t??this.defaults)}parser(o,t){return z.parse(o,t??this.defaults)}parseMarkdown(o){return(t,e)=>{let a={...e},r={...this.defaults,...a},s=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&a.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=o),r.async)return(async()=>{let i=r.hooks?await r.hooks.preprocess(t):t,l=await(r.hooks?await r.hooks.provideLexer():o?M.lex:M.lexInline)(i,r),n=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(n,r.walkTokens));let d=await(r.hooks?await r.hooks.provideParser():o?z.parse:z.parseInline)(n,r);return r.hooks?await r.hooks.postprocess(d):d})().catch(s);try{r.hooks&&(t=r.hooks.preprocess(t));let i=(r.hooks?r.hooks.provideLexer():o?M.lex:M.lexInline)(t,r);r.hooks&&(i=r.hooks.processAllTokens(i)),r.walkTokens&&this.walkTokens(i,r.walkTokens);let l=(r.hooks?r.hooks.provideParser():o?z.parse:z.parseInline)(i,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(i){return s(i)}}}onError(o,t){return e=>{if(e.message+=`
|
|
59
|
+
Please report this to https://github.com/markedjs/marked.`,o){let a="<p>An error occurred:</p><pre>"+A(e.message+"",!0)+"</pre>";return t?Promise.resolve(a):a}if(t)return Promise.reject(e);throw e}}},V=new Bt;C.options=C.setOptions=function(o){return V.setOptions(o),C.defaults=V.defaults,Mt(C.defaults),C};C.getDefaults=Te;C.defaults=R;C.use=function(...o){return V.use(...o),C.defaults=V.defaults,Mt(C.defaults),C};C.walkTokens=function(o,t){return V.walkTokens(o,t)};C.parseInline=V.parseInline;C.Parser=z;C.parser=z.parse;C.Renderer=X;C.TextRenderer=ze;C.Lexer=M;C.lexer=M.lex;C.Tokenizer=J;C.Hooks=_;C.parse=C;_r=C.options,Or=C.setOptions,jr=C.use,Wr=C.walkTokens,Ur=C.parseInline,Yr=C,Zr=z.parse,Gr=M.lex});var O=class{parse(t){if(!t)throw new Error("Schema es requerido");if(!t.fields&&!t.steps)throw new Error("Schema debe tener fields o steps");if(t.steps){for(let r of t.steps)if(!r.fields||r.fields.length===0)throw new Error("Cada step debe tener al menos un field")}let e=t.fields?this.normalizeFields(t.fields):[],a=t.steps?t.steps.map(r=>({...r,fields:this.normalizeFields(r.fields)})):void 0;return{fields:e,steps:a,isWizard:!!(t.steps&&t.steps.length>0)}}normalizeFields(t){return t.map((e,a)=>{if(!e.type)throw new Error(`Field en \xEDndice ${a} debe tener un type`);if(!e.name)throw new Error(`Field en \xEDndice ${a} debe tener un name`);return this.validateFieldType(e,a),this.applyDefaults(e)})}validateFieldType(t,e){if(!["text","email","number","password","textarea","select","checkbox","radio","switch","date","file","file-drop","map","rating","slider","colorpicker","array","group","row","custom","quantity","accordion-select","image-grid-select","otp","markdown"].includes(t.type))throw new Error(`Field en \xEDndice ${e} tiene un type inv\xE1lido: ${t.type}`);switch(t.type){case"select":case"radio":case"accordion-select":case"image-grid-select":if(!("options"in t)||!t.options||t.options.length===0)throw new Error(`Field "${t.name}" de tipo ${t.type} debe tener options`);break;case"array":if(!("itemSchema"in t)||!t.itemSchema)throw new Error(`Field "${t.name}" de tipo array debe tener itemSchema`);if("minItems"in t){let r=t.minItems;if(r<0)throw new Error(`Field "${t.name}" de tipo array: minItems debe ser >= 0`);if("maxItems"in t){let s=t.maxItems;if(r>s)throw new Error(`Field "${t.name}" de tipo array: minItems (${r}) no puede ser mayor que maxItems (${s})`)}}break;case"group":if(!("fields"in t)||!t.fields||t.fields.length===0)throw new Error(`Field "${t.name}" de tipo group debe tener fields`);break;case"row":if(!("fields"in t)||!t.fields||t.fields.length===0)throw new Error(`Field "${t.name}" de tipo row debe tener fields`);break;case"colorpicker":if("defaultValue"in t&&t.defaultValue!=null&&!/^#[0-9A-Fa-f]{6}$/.test(String(t.defaultValue)))throw new Error(`Field "${t.name}" de tipo colorpicker debe tener defaultValue en formato hex (#RRGGBB)`);break}"leadingIcon"in t&&t.leadingIcon&&this.validateSlotContent(t.leadingIcon,t.name,"leadingIcon"),"trailingIcon"in t&&t.trailingIcon&&this.validateSlotContent(t.trailingIcon,t.name,"trailingIcon")}validateSlotContent(t,e,a){if(!t.type||!["image","html"].includes(t.type))throw new Error(`Field "${e}" ${a} debe tener type 'image' o 'html'`);if(t.type==="image"&&(!t.src||typeof t.src!="string"))throw new Error(`Field "${e}" ${a} con type 'image' debe tener src`);if(t.type==="html"&&(!t.html||typeof t.html!="string"))throw new Error(`Field "${e}" ${a} con type 'html' debe tener html`)}applyDefaults(t){let e={disabled:!1,hidden:!1};switch(t.type){case"checkbox":case"switch":"checked"in t||(e.checked=!1);break;case"select":case"accordion-select":case"image-grid-select":"multiple"in t||(e.multiple=!1),t.type==="image-grid-select"&&("columns"in t||(e.columns=3),"imageSize"in t||(e.imageSize="medium"));break;case"file":"multiple"in t||(e.multiple=!1);break;case"quantity":"min"in t||(e.min=0),"step"in t||(e.step=1);break;case"otp":"length"in t||(e.length=6),"numeric"in t||(e.numeric=!0);break;case"slider":"min"in t||(e.min=0),"max"in t||(e.max=100),"step"in t||(e.step=1);break;case"rating":"max"in t||(e.max=5);break;case"colorpicker":(!("defaultValue"in t)||t.defaultValue==null)&&(e.defaultValue="#000000");break}return{...e,...t}}getAllFields(t){let e=this.parse(t),a=[],r=s=>{for(let i of s)a.push(i),i.type==="group"&&"fields"in i&&r(i.fields),i.type==="row"&&"fields"in i&&r(i.fields),i.type==="array"&&"itemSchema"in i&&i.itemSchema.fields&&r(i.itemSchema.fields)};if(e.fields&&r(e.fields),e.steps)for(let s of e.steps)r(s.fields);return a}};function Yt(o){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o);if(!t){let e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(o);return e?[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)].join(", "):"0, 123, 255"}return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)].join(", ")}var Zt={primary:"#007bff",secondary:"#6c757d",error:"#dc3545",success:"#28a745",text:"#212529",labelColor:"#212529",border:"#ddd",background:"#ffffff",groupBackground:"var(--easy-form-group-background)",groupTitle:"#212529",groupBorder:"#ddd"};function j(o){return{...Zt,...o}}function st(o){return`
|
|
60
60
|
:host {
|
|
61
61
|
display: block;
|
|
62
62
|
--easy-form-primary: ${o.primary};
|
|
@@ -450,6 +450,125 @@ Please report this to https://github.com/markedjs/marked.`,o){let a="<p>An error
|
|
|
450
450
|
color: var(--easy-form-secondary);
|
|
451
451
|
font-size: 0.875rem;
|
|
452
452
|
}
|
|
453
|
+
.easy-form-markdown-tabs {
|
|
454
|
+
border: 1px solid var(--easy-form-border);
|
|
455
|
+
border-radius: 4px;
|
|
456
|
+
overflow: hidden;
|
|
457
|
+
}
|
|
458
|
+
.easy-form-markdown-tabs-header {
|
|
459
|
+
display: flex;
|
|
460
|
+
background: var(--easy-form-group-background);
|
|
461
|
+
border-bottom: 1px solid var(--easy-form-border);
|
|
462
|
+
}
|
|
463
|
+
.easy-form-markdown-tabs .easy-form-markdown-tab {
|
|
464
|
+
flex: 1;
|
|
465
|
+
padding: 0.5rem 1rem;
|
|
466
|
+
background: transparent;
|
|
467
|
+
border: none;
|
|
468
|
+
cursor: pointer;
|
|
469
|
+
font-size: 0.875rem;
|
|
470
|
+
color: var(--easy-form-secondary);
|
|
471
|
+
transition: all 0.15s;
|
|
472
|
+
}
|
|
473
|
+
.easy-form-markdown-tabs .easy-form-markdown-tab:hover {
|
|
474
|
+
background: var(--easy-form-group-background);
|
|
475
|
+
color: var(--easy-form-text);
|
|
476
|
+
}
|
|
477
|
+
.easy-form-markdown-tabs .easy-form-markdown-tab.active {
|
|
478
|
+
background: var(--easy-form-background);
|
|
479
|
+
color: var(--easy-form-primary);
|
|
480
|
+
border-bottom: 2px solid var(--easy-form-primary);
|
|
481
|
+
}
|
|
482
|
+
.easy-form-markdown-tabs-content {
|
|
483
|
+
display: flex;
|
|
484
|
+
flex-direction: column;
|
|
485
|
+
}
|
|
486
|
+
.easy-form-markdown-tabs-content .easy-form-markdown-toolbar {
|
|
487
|
+
border-bottom: 1px solid var(--easy-form-border);
|
|
488
|
+
border-radius: 0;
|
|
489
|
+
}
|
|
490
|
+
.easy-form-markdown-tabs-content .easy-form-markdown-textarea {
|
|
491
|
+
border-radius: 0;
|
|
492
|
+
}
|
|
493
|
+
.easy-form-markdown-tabs-content .easy-form-markdown-preview {
|
|
494
|
+
border-radius: 0;
|
|
495
|
+
border-top: 1px solid var(--easy-form-border);
|
|
496
|
+
}
|
|
497
|
+
.easy-form-markdown-preview-mode {
|
|
498
|
+
position: relative;
|
|
499
|
+
border: 1px solid var(--easy-form-border);
|
|
500
|
+
border-radius: 4px;
|
|
501
|
+
overflow: hidden;
|
|
502
|
+
}
|
|
503
|
+
.easy-form-markdown-preview-mode .easy-form-markdown-textarea-invisible {
|
|
504
|
+
position: absolute;
|
|
505
|
+
top: 0;
|
|
506
|
+
left: 0;
|
|
507
|
+
width: 1px;
|
|
508
|
+
height: 1px;
|
|
509
|
+
opacity: 0;
|
|
510
|
+
pointer-events: none;
|
|
511
|
+
}
|
|
512
|
+
.easy-form-markdown-preview-mode-content {
|
|
513
|
+
padding: 0.75rem;
|
|
514
|
+
overflow-y: auto;
|
|
515
|
+
background: var(--easy-form-background);
|
|
516
|
+
color: var(--easy-form-text);
|
|
517
|
+
font-size: 0.875rem;
|
|
518
|
+
line-height: 1.6;
|
|
519
|
+
height: 100%;
|
|
520
|
+
box-sizing: border-box;
|
|
521
|
+
}
|
|
522
|
+
.easy-form-markdown-preview-mode-content h1,
|
|
523
|
+
.easy-form-markdown-preview-mode-content h2,
|
|
524
|
+
.easy-form-markdown-preview-mode-content h3,
|
|
525
|
+
.easy-form-markdown-preview-mode-content h4,
|
|
526
|
+
.easy-form-markdown-preview-mode-content h5,
|
|
527
|
+
.easy-form-markdown-preview-mode-content h6 {
|
|
528
|
+
margin-top: 1rem;
|
|
529
|
+
margin-bottom: 0.5rem;
|
|
530
|
+
font-weight: 600;
|
|
531
|
+
line-height: 1.3;
|
|
532
|
+
}
|
|
533
|
+
.easy-form-markdown-preview-mode-content h1 { font-size: 1.5rem; }
|
|
534
|
+
.easy-form-markdown-preview-mode-content h2 { font-size: 1.25rem; }
|
|
535
|
+
.easy-form-markdown-preview-mode-content h3 { font-size: 1.125rem; }
|
|
536
|
+
.easy-form-markdown-preview-mode-content p { margin: 0.5rem 0; }
|
|
537
|
+
.easy-form-markdown-preview-mode-content code {
|
|
538
|
+
background: rgba(0,0,0,0.06);
|
|
539
|
+
padding: 0.125rem 0.25rem;
|
|
540
|
+
border-radius: 3px;
|
|
541
|
+
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
|
|
542
|
+
font-size: 0.8125rem;
|
|
543
|
+
}
|
|
544
|
+
.easy-form-markdown-preview-mode-content pre {
|
|
545
|
+
background: rgba(0,0,0,0.04);
|
|
546
|
+
padding: 0.75rem;
|
|
547
|
+
border-radius: 4px;
|
|
548
|
+
overflow-x: auto;
|
|
549
|
+
}
|
|
550
|
+
.easy-form-markdown-preview-mode-content pre code {
|
|
551
|
+
background: none;
|
|
552
|
+
padding: 0;
|
|
553
|
+
}
|
|
554
|
+
.easy-form-markdown-preview-mode-content ul,
|
|
555
|
+
.easy-form-markdown-preview-mode-content ol {
|
|
556
|
+
padding-left: 1.5rem;
|
|
557
|
+
margin: 0.5rem 0;
|
|
558
|
+
}
|
|
559
|
+
.easy-form-markdown-preview-mode-content blockquote {
|
|
560
|
+
border-left: 3px solid var(--easy-form-primary);
|
|
561
|
+
margin: 0.5rem 0;
|
|
562
|
+
padding-left: 0.75rem;
|
|
563
|
+
color: var(--easy-form-secondary);
|
|
564
|
+
}
|
|
565
|
+
.easy-form-markdown-preview-mode-content a {
|
|
566
|
+
color: var(--easy-form-primary);
|
|
567
|
+
}
|
|
568
|
+
.easy-form-markdown-preview-mode-content img {
|
|
569
|
+
max-width: 100%;
|
|
570
|
+
height: auto;
|
|
571
|
+
}
|
|
453
572
|
.easy-form-required {
|
|
454
573
|
color: var(--easy-form-error);
|
|
455
574
|
}
|
|
@@ -2532,7 +2651,7 @@ Please report this to https://github.com/markedjs/marked.`,o){let a="<p>An error
|
|
|
2532
2651
|
background-position: right 1rem center;
|
|
2533
2652
|
padding-right: 2.5rem;
|
|
2534
2653
|
}
|
|
2535
|
-
`}function te(o,t){let e=st(t),a=Gt(o,t);return e+a}function Gt(o,t){switch(o){case"plano":return De(t);case"tradicional":return it(t);case"material":return ot(t);case"rounded-shadow":return nt(t);case"lines":return lt(t);case"shadcn":return dt(t);case"chakra":return ct(t);case"mantine":return pt(t);case"glass":return mt(t);case"bordered":return ut(t);case"minimal":return ft(t);case"efc":return ht(t);default:return De(t)}}var gt={phone:{pattern:"(999) 999-9999",placeholder:"_"},"phone-us":{pattern:"(999) 999-9999",placeholder:"_"},"phone-international":{pattern:"+99 999 999 9999",placeholder:"_"},date:{pattern:"99/99/9999",placeholder:"_"},"date-us":{pattern:"99/99/9999",placeholder:"_"},"date-eu":{pattern:"99-99-9999",placeholder:"_"},"credit-card":{pattern:"9999 9999 9999 9999",placeholder:"_"},ssn:{pattern:"999-99-9999",placeholder:"_"},"zip-code":{pattern:"99999",placeholder:"_"},currency:{pattern:"$999,999.99",placeholder:"_",transform:o=>{let t=o.replace(/[^\d.]/g,"");return(parseFloat(t)||0).toFixed(2)}},percentage:{pattern:"999%",placeholder:"_",transform:o=>o.replace(/[^\d]/g,"")},time:{pattern:"99:99",placeholder:"_"},datetime:{pattern:"99/99/9999 99:99",placeholder:"_"}};function Ve(o){return gt[o]}var re="El valor contiene caracteres o patrones no permitidos",Kt=[/\b(union|select|insert|update|delete|drop|exec|execute|declare)\s+(all\s+)?(select|from|into|table)/i,/\b(or|and)\s+['"]?\d+['"]?\s*=\s*['"]?\d+/i,/;\s*(drop|delete|truncate|alter)\s+/i,/--\s*$/,/\/\*[\s\S]*\*\//,/'\s*or\s+'1'\s*=\s*'1/i,/"\s*or\s+"1"\s*=\s*"1/i,/\bexec\s*\(/i,/\bxp_\w+/i,/<script\b[\s\S]*?>[\s\S]*?<\/script>/i,/<script\b/i,/javascript\s*:/i,/vbscript\s*:/i,/on\w+\s*=\s*["'][^"']*["']/i,/on\w+\s*=\s*[^\s>]+/i,/<iframe\b/i,/<object\b/i,/<embed\b/i,/\beval\s*\(/i,/document\.(cookie|write|location)/i,/window\.(location|open|eval)/i,/[;&|]\s*(ls|cat|rm|wget|curl|nc|bash|sh|python|perl)\s/i,/\$\s*\([^)]+\)/,/`[^`]+`/,/\|\s*\w+/,/\$\s*where\b/i,/\$\s*gt\b|\$\s*ne\b|\$\s*regex\b/i,/\{\{[^}]*\}\}/,/\$\{[^}]*\}/];function bt(o){if(typeof o!="string"||o.length===0||o.trim().length===0)return!1;for(let e of Kt)if(e.test(o))return!0;return!1}function W(o){return o==null?!0:typeof o=="string"?!bt(o):Array.isArray(o)?o.every(t=>W(t)):typeof o=="object"?Object.values(o).every(t=>W(t)):!0}var U=class{constructor(t){this.attempts=0;this.lockedUntil=null;this.unlockCheckInterval=null;this.maxAttempts=Math.max(1,t.maxAttempts),this.blockDurationMs=(t.blockDurationMinutes??5)*60*1e3,this.storageKey=t.storageKey,this.onLocked=t.onLocked,this.onUnlocked=t.onUnlocked,this.storageKey&&typeof sessionStorage<"u"&&this.loadFromStorage()}loadFromStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t=sessionStorage.getItem(this.storageKey);if(t){let e=JSON.parse(t);this.attempts=e.attempts??0,this.lockedUntil=e.lockedUntil??null,this.checkExpiration()}}catch{}}saveToStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t={attempts:this.attempts,lockedUntil:this.lockedUntil??void 0};sessionStorage.setItem(this.storageKey,JSON.stringify(t))}catch{}}checkExpiration(){return this.lockedUntil===null?!1:Date.now()>=this.lockedUntil?(this.reset(),this.onUnlocked?.(),!0):!1}startUnlockCheck(){this.unlockCheckInterval||(this.unlockCheckInterval=setInterval(()=>{this.checkExpiration()&&this.stopUnlockCheck()},1e3))}stopUnlockCheck(){this.unlockCheckInterval&&(clearInterval(this.unlockCheckInterval),this.unlockCheckInterval=null)}incrementAttempts(){this.attempts++,this.attempts>=this.maxAttempts?(this.lockedUntil=Date.now()+this.blockDurationMs,this.saveToStorage(),this.onLocked?.(this.blockDurationMs),this.startUnlockCheck()):this.saveToStorage()}isLocked(){return this.checkExpiration()?!1:this.lockedUntil!==null&&Date.now()<this.lockedUntil}getRemainingBlockTimeMs(){return this.checkExpiration()||this.lockedUntil===null?0:Math.max(0,this.lockedUntil-Date.now())}reset(){this.attempts=0,this.lockedUntil=null,this.stopUnlockCheck(),this.saveToStorage()}getAttempts(){return this.attempts}};function H(o){return o==null?"":typeof o=="boolean"?o?"true":"false":typeof o=="object"?JSON.stringify(o):String(o)}function q(o){if(!o)return null;try{return JSON.parse(o)}catch{return o}}function Wa(o="ef"){return`${o}-${Math.random().toString(36).substr(2,9)}`}function I(o,t){return t.split(".").reduce((e,a)=>e?.[a],o)}function B(o,t,e){let a=t.split("."),r=a.pop(),s=a.reduce((i,l)=>((!i[l]||typeof i[l]!="object")&&(i[l]={}),i[l]),o);s[r]=e}function yt(o){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)}function Ua(o){return o.replace(/[^a-zA-Z0-9-_]/g,"-")}var P=class{evaluateCondition(t,e){let a=this.getFieldValue(t.field,e);return this.compareValues(a,t.operator,t.value)}evaluateConditions(t,e,a="and"){let r=Array.isArray(t)?t:[t];return r.length===0?!0:a==="and"?r.every(s=>this.evaluateCondition(s,e)):r.some(s=>this.evaluateCondition(s,e))}evaluateDependencies(t,e){let a=!0,r=!0,s=!1;if(t.show&&(a=this.evaluateConditions(t.show,e)),t.hide){let i=this.evaluateConditions(t.hide,e);a=a&&!i}if(t.enable&&(r=this.evaluateConditions(t.enable,e)),t.disable){let i=this.evaluateConditions(t.disable,e);r=r&&!i}if(t.required&&(s=this.evaluateConditions(t.required,e)),t.optional){let i=this.evaluateConditions(t.optional,e);s=s&&!i}return{visible:a,enabled:r,required:s}}getFieldValue(t,e){if(t in e)return e[t];let a=t.split("."),r=e;for(let s of a){if(r==null)return null;r=r[s]}return r}compareValues(t,e,a){switch(e){case"equals":return this.deepEqual(t,a);case"notEquals":return!this.deepEqual(t,a);case"contains":return Array.isArray(t)?t.includes(a):typeof t=="string"?t.includes(String(a)):!1;case"notContains":return!this.compareValues(t,"contains",a);case"greaterThan":return this.toNumber(t)>this.toNumber(a);case"lessThan":return this.toNumber(t)<this.toNumber(a);case"greaterThanOrEqual":return this.toNumber(t)>=this.toNumber(a);case"lessThanOrEqual":return this.toNumber(t)<=this.toNumber(a);case"in":return Array.isArray(a)?a.includes(t):!1;case"notIn":return!this.compareValues(t,"in",a);case"isEmpty":return t==null||t===""||Array.isArray(t)&&t.length===0;case"isNotEmpty":return!this.compareValues(t,"isEmpty",a);case"regex":try{return(typeof a=="string"?new RegExp(a):a).test(String(t||""))}catch{return!1}default:return!1}}deepEqual(t,e){if(t===e)return!0;if(t===null||e===null||t===void 0||e===void 0)return t===e;if(typeof t!=typeof e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((a,r)=>this.deepEqual(a,e[r]));if(typeof t=="object"){let a=Object.keys(t),r=Object.keys(e);return a.length!==r.length?!1:a.every(s=>this.deepEqual(t[s],e[s]))}return!1}toNumber(t){if(typeof t=="number")return t;if(typeof t=="string"){let e=parseFloat(t);return isNaN(e)?0:e}return 0}};var Y=class{constructor(){this.conditionEngine=new P}async validateField(t,e){return this.validateFieldWithValidations(t,e,t.validations||[])}async validateFieldWithValidations(t,e,a){let r=[];if(!a||a.length===0)return r;for(let s of a){let i=await this.validateValue(s,e);i.isValid||r.push(i.message||this.getDefaultMessage(s))}return r}async validateValue(t,e){switch(t.type){case"required":return this.validateRequired(e);case"email":return this.validateEmail(e);case"minLength":return this.validateMinLength(e,t.value);case"maxLength":return this.validateMaxLength(e,t.value);case"min":return this.validateMin(e,t.value);case"max":return this.validateMax(e,t.value);case"pattern":return this.validatePattern(e,t.value);case"custom":return await this.validateCustom(e,t);case"noInjection":return this.validateNoInjection(e,t);default:return{isValid:!0}}}validateRequired(t){let e=t!=null&&t!==""&&!(Array.isArray(t)&&t.length===0);return{isValid:e,message:e?void 0:"Este campo es requerido"}}validateEmail(t){if(!t)return{isValid:!0};let e=typeof t=="string"&&yt(t);return{isValid:e,message:e?void 0:"Debe ser un email v\xE1lido"}}validateMinLength(t,e){if(!t)return{isValid:!0};let r=String(t).length>=e;return{isValid:r,message:r?void 0:`Debe tener al menos ${e} caracteres`}}validateMaxLength(t,e){if(!t)return{isValid:!0};let r=String(t).length<=e;return{isValid:r,message:r?void 0:`Debe tener m\xE1ximo ${e} caracteres`}}validateMin(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a>=e;return{isValid:r,message:r?void 0:`Debe ser mayor o igual a ${e}`}}validateMax(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a<=e;return{isValid:r,message:r?void 0:`Debe ser menor o igual a ${e}`}}validatePattern(t,e){if(!t)return{isValid:!0};let a;if(e instanceof RegExp)a=e;else if(typeof e=="string")try{a=new RegExp(e)}catch{return console.warn("Invalid regex pattern:",e),{isValid:!0}}else return console.warn("Pattern validation expects string or RegExp, got:",typeof e,e),{isValid:!0};let r=a.test(String(t));return{isValid:r,message:r?void 0:"El formato no es v\xE1lido"}}validateNoInjection(t,e){if(t==null||t==="")return{isValid:!0};let a=W(t);return{isValid:a,message:a?void 0:e.message||re}}async validateCustom(t,e){try{let a=await e.validator(t);return{isValid:!!a,message:a?void 0:e.message||"Validaci\xF3n fallida"}}catch{return{isValid:!1,message:e.message||"Error en la validaci\xF3n"}}}getDefaultMessage(t){switch(t.type){case"required":return"Este campo es requerido";case"email":return"Debe ser un email v\xE1lido";case"minLength":return`Debe tener al menos ${t.value} caracteres`;case"maxLength":return`Debe tener m\xE1ximo ${t.value} caracteres`;case"min":return`Debe ser mayor o igual a ${t.value}`;case"max":return`Debe ser menor o igual a ${t.value}`;case"pattern":return"El formato no es v\xE1lido";case"custom":return"Validaci\xF3n fallida";case"noInjection":return re;default:return"Campo inv\xE1lido"}}shouldValidateField(t,e){if(t.hidden||t.disabled)return!1;if(t.dependencies){let a=this.conditionEngine.evaluateDependencies(t.dependencies,e);if(!a.visible||!a.enabled)return!1}return!0}async validateForm(t,e){let a={};for(let r of t)if(this.shouldValidateField(r,e))if(r.type==="array"&&"itemSchema"in r){let l=r.itemSchema?.fields||[],n=e[r.name];if(Array.isArray(n))for(let c=0;c<n.length;c++){let m=n[c];for(let p of l){let u=`${r.name}.${c}.${p.name}`,h=m?.[p.name];if(!this.shouldValidateField(p,e))continue;let g=await this.validateField(p,h);g.length>0&&(a[u]=g)}}let d=await this.validateArrayField(r,n);d.length>0&&(a[r.name]=d)}else{let s=e[r.name],i=await this.validateField(r,s);i.length>0&&(a[r.name]=i)}return a}async validateArrayField(t,e){let a=[],r=t;return r.minItems!==void 0&&(Array.isArray(e)&&e.length>=r.minItems||a.push(`Debe tener al menos ${r.minItems} elementos`)),r.maxItems!==void 0&&(Array.isArray(e)&&e.length<=r.maxItems||a.push(`Debe tener m\xE1ximo ${r.maxItems} elementos`)),a}};var Z=class{constructor(){this.wizardState=null;this.schema=null;this.dependencyCache=new Map;this.fieldDependencies=new Map;this.parser=new _,this.validator=new Y,this.conditionEngine=new P,this.state=this.createInitialState()}createInitialState(){return{values:{},errors:{},touched:{},isValid:!0,isSubmitting:!1}}initializeSchema(t,e){this.schema=this.parser.parse(t),this.initializeValues(e),this.initializeWizard(),this.buildDependencyMap()}extractAllFields(t){let e=[];for(let a of t)e.push(a),a.type==="group"&&"fields"in a&&e.push(...this.extractAllFields(a.fields)),a.type==="row"&&"fields"in a&&e.push(...this.extractAllFields(a.fields));return e}getArrayItemOnlyFieldNames(t){let e=new Set(t.map(r=>r.name)),a=new Set;for(let r of t)if(r.type==="array"&&"itemSchema"in r&&r.itemSchema?.fields)for(let s of r.itemSchema.fields)e.has(s.name)||a.add(s.name);return a}extractAllFieldsWithArrays(t,e="",a="root"){let r=[];for(let s of t){let i=e?`${e}.${s.name}`:s.name,l=e||"";r.push({field:s,fullPath:i,containerType:a,containerPath:l}),s.type==="group"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"group")),s.type==="row"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"row")),s.type==="array"&&"itemSchema"in s&&s.itemSchema?.fields&&r.push(...this.extractAllFieldsWithArrays(s.itemSchema.fields,s.name,"array"))}return r}buildDependencyMap(){if(this.fieldDependencies.clear(),this.dependencyCache.clear(),!this.schema)return;let t=this.schema.isWizard?this.schema.steps.flatMap(a=>a.fields):this.schema.fields||[],e=this.extractAllFieldsWithArrays(t);for(let{field:a,fullPath:r,containerType:s,containerPath:i}of e){if(!a.dependencies)continue;let l=this.extractObservedFields(a.dependencies);for(let n of l)this.fieldDependencies.has(n)||this.fieldDependencies.set(n,new Set),this.fieldDependencies.get(n).add(a.name),r!==a.name&&this.fieldDependencies.get(n).add(r),s==="array"&&i&&(this.fieldDependencies.has(i)||this.fieldDependencies.set(i,new Set),this.fieldDependencies.get(i).add(r))}}extractObservedFields(t){let e=new Set,a=s=>{s&&s.field&&e.add(s.field)},r=s=>{Array.isArray(s)?s.forEach(a):s&&a(s)};return t.show&&r(t.show),t.hide&&r(t.hide),t.enable&&r(t.enable),t.disable&&r(t.disable),t.required&&r(t.required),t.optional&&r(t.optional),e}initializeValues(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(l=>l.fields):this.schema.fields||[],a=this.extractAllFields(e),r={...this.state.values},s={};if(t)for(let l in t){let n=t[l];n!=null&&B(s,l,n)}for(let l of a){let n=I(s,l.name);if(n!=null)continue;let d=I(r,l.name);d!=null?B(s,l.name,d):this.initializeFieldValue(l,s)}let i=this.getArrayItemOnlyFieldNames(e);for(let l in r)i.has(l)||l in s||(s[l]=r[l]);for(let l of e)if(l.type==="array"&&"minItems"in l&&"itemSchema"in l){let n=l,d=n.minItems??0;if(d>=1&&n.itemSchema?.fields?.length){let c=I(s,l.name);if(Array.isArray(c)&&c.length<d){let m=[...c];for(let p=c.length;p<d;p++){let u={};for(let h of n.itemSchema.fields)this.initializeFieldValue(h,u);m.push(u)}B(s,l.name,m)}}}for(let l of i)l in s&&delete s[l];this.state.values=s}initializeFieldValue(t,e){if(t.defaultValue!==void 0)e[t.name]=t.defaultValue;else switch(t.type){case"checkbox":case"switch":e[t.name]=t.checked||!1;break;case"select":"multiple"in t&&t.multiple?e[t.name]=[]:e[t.name]=null;break;case"array":{let a=t,r=a.minItems??0,s=a.itemSchema?.fields;if(r>=1&&s?.length){let i=[];for(let l=0;l<r;l++){let n={};for(let d of s)this.initializeFieldValue(d,n);i.push(n)}e[t.name]=i}else e[t.name]=[];break}case"group":if(e[t.name]={},"fields"in t)for(let a of t.fields)this.initializeFieldValue(a,e[t.name]);break;case"colorpicker":e[t.name]=t.defaultValue??"#000000";break;default:e[t.name]=null}}initializeWizard(){if(!this.schema||!this.schema.isWizard){this.wizardState=null;return}this.wizardState={currentStep:0,totalSteps:this.schema.steps.length,completedSteps:[]}}getState(){return{...this.state}}getWizardState(){return this.wizardState?{...this.wizardState}:null}getValue(t){return I(this.state.values,t)}createDefaultArrayItem(t){let a=t.itemSchema?.fields;if(!a?.length)return{};let r={};for(let s of a)this.initializeFieldValue(s,r);return r}async setValue(t,e){B(this.state.values,t,e),this.state.touched[t]=!0,this.invalidateDependencyCache(t),this.state.touched[t]&&this.schema&&await this.validateField(t);let a=this.fieldDependencies.get(t);if(a)for(let r of a)await this.validateField(r);this.updateValidity()}invalidateDependencyCache(t){let e=this.fieldDependencies.get(t);if(e)for(let s of e){this.dependencyCache.delete(s);let i=this.addArrayIndexToPath(t,s);i&&this.dependencyCache.delete(i)}let a=t.replace(/\[\d+\]/g,"");if(a!==t){if(e=this.fieldDependencies.get(a),e)for(let i of e){this.dependencyCache.delete(i);let l=t.match(/\[(\d+)\]/);if(l){let n=i.includes("[")?i:`${i.split(".").slice(0,-1).join(".")}[${l[1]}].${i.split(".").pop()}`;this.dependencyCache.delete(n)}}let s=a.split(".").pop();if(s&&s!==a&&(e=this.fieldDependencies.get(s),e))for(let i of e){this.dependencyCache.delete(i);let l=t.match(/\[(\d+)\]/);if(l){let d=`${t.split(".")[0].replace(/\[\d+\]/,"")}[${l[1]}].${i}`;this.dependencyCache.delete(d)}}}let r=t.split(".");for(let s=1;s<r.length;s++){if(r[s].includes("["))continue;let i=r.slice(s).join(".");if(e=this.fieldDependencies.get(i),e)for(let l of e)this.dependencyCache.delete(l),this.dependencyCache.delete(`${r[0]}.${i}`)}this.dependencyCache.delete(t)}addArrayIndexToPath(t,e){let a=t.match(/\[(\d+)\]/);if(!a)return null;let r=a[1],s=t.split(".")[0];if(e.startsWith(s)){let i=e.split(".");if(i.length>1)return`${i[0]}[${r}].${i.slice(1).join(".")}`}return null}setValueWithoutValidation(t,e){B(this.state.values,t,e),this.invalidateDependencyCache(t)}async validateField(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],r=this.extractAllFields(e).find(n=>n.name===t);if(!r)return;if(!this.getFieldVisibility(t)){delete this.state.errors[t];return}let s=this.getValue(t),i=this.getActiveValidations(r),l=await this.validator.validateFieldWithValidations(r,s,i);l.length>0?this.state.errors[t]=l:delete this.state.errors[t]}getActiveValidations(t){let e=[...t.validations||[]],a=["text","email","password","textarea"],r=t.skipInjectionValidation??t.props?.skipInjectionValidation;a.includes(t.type)&&!r&&!e.some(l=>l.type==="noInjection")&&(e=[{type:"noInjection"},...e]);let s=this.getFieldRequired(t.name),i=e.some(l=>l.type==="required");if(s&&!i?e=[{type:"required"},...e]:!s&&i&&(e=e.filter(l=>l.type!=="required")),t.conditionalValidations)for(let l of t.conditionalValidations)this.conditionEngine.evaluateConditions(l.condition,this.state.values)&&(e=[...e,...l.validations]);return e}async validateForm(){if(!this.schema)return{};let t=this.schema.isWizard?this.schema.steps.flatMap(r=>r.fields):this.schema.fields||[],e=this.extractAllFields(t),a=await this.validator.validateForm(e,this.state.values);return this.state.errors=a,this.updateValidity(),a}updateValidity(){this.state.isValid=Object.keys(this.state.errors).length===0}setTouched(t){this.state.touched[t]=!0}getErrors(t){return this.state.errors[t]||[]}getAllErrors(){return{...this.state.errors}}reset(){this.state=this.createInitialState(),this.schema&&(this.initializeValues(),this.initializeWizard())}nextStep(){return this.wizardState&&this.wizardState.currentStep<this.wizardState.totalSteps-1?(this.wizardState.currentStep++,!0):!1}previousStep(){return this.wizardState&&this.wizardState.currentStep>0?(this.wizardState.currentStep--,!0):!1}goToStep(t){return this.wizardState&&t>=0&&t<this.wizardState.totalSteps?(this.wizardState.currentStep=t,!0):!1}completeStep(t){this.wizardState&&(this.wizardState.completedSteps.includes(t)||this.wizardState.completedSteps.push(t))}setSubmitting(t){this.state.isSubmitting=t}getCurrentStepFields(){return!this.schema||!this.schema.isWizard||!this.wizardState?this.schema?.fields||[]:this.schema.steps[this.wizardState.currentStep].fields}getFieldVisibility(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.visible;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(p=>p.fields):this.schema.fields||[],r=this.extractAllFieldsWithArrays(a),s=r.find(p=>p.fullPath===t||p.field.name===t);if(!s){let p=t.replace(/\[\d+\]/g,"");s=r.find(u=>u.field.name===p||u.fullPath===p)}if(!s){let p=t.split(".").pop();s=r.find(u=>u.field.name===p)}if(!s||!s.field.dependencies)return!s?.field.hidden;let{field:i,containerType:l,containerPath:n}=s,d=s.field.dependencies,c={...this.state.values};if(l==="array"&&n){let p,u=g=>{if(g)return Array.isArray(g)?g[0]?.field:g.field};if(p=u(d.show)||u(d.hide)||u(d.enable)||u(d.disable)||u(d.required)||u(d.optional),p&&p){let g=t.match(/\[(\d+)\]/),f=g?parseInt(g[1],10):null,y=null;if(f!==null){let x=I(this.state.values,n);if(Array.isArray(x)&&x[f]&&(y=x[f][p]),y==null){let b=`${n}[${f}]`,w=this.state.values[b];w&&typeof w=="object"&&(y=w[p])}}else{let x=I(this.state.values,n);if(Array.isArray(x)){for(let b of x)if(b&&b[p]!==void 0){y=b[p];break}}}if(y!=null){let x={...this.state.values};x[p]=y;let b=this.conditionEngine.evaluateDependencies(d,x);return this.dependencyCache.set(t,b),b.visible&&!i.hidden}}let h={visible:!0,enabled:!0,required:!1};return this.dependencyCache.set(t,h),h.visible&&!i.hidden}else if(n){let p=I(this.state.values,n);if(p&&typeof p=="object"){let u=(g,f="")=>{let y={},x=Object.entries(g);for(let[b,w]of x){let S=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null&&Object.assign(y,u(w,S))}for(let[b,w]of x){let S=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null||S in y||(y[S]=w)}return y},h=u(p);c={...this.state.values,...h}}}let m=this.conditionEngine.evaluateDependencies(d,c);return this.dependencyCache.set(t,m),m.visible&&!i.hidden}getFieldEnabled(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.enabled;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(l=>l.fields):this.schema.fields||[],s=this.extractAllFields(a).find(l=>l.name===t);if(!s)return!0;if(s.disabled)return!1;if(!s.dependencies)return!0;let i=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,i),i.enabled}getFieldRequired(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.required;if(!this.schema)return!1;let a=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],s=this.extractAllFields(a).find(n=>n.name===t);if(!s)return!1;let i=s.validations?.some(n=>n.type==="required")||!1;if(!s.dependencies)return i;let l=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,l),l.required||i}getDependentFields(t){return Array.from(this.fieldDependencies.get(t)||[])}};var v=class{constructor(t,e,a,r,s){this.field=t,this.value=e,this.error=a,this.onChange=r,this.onBlur=s}createInputWithSlots(t){let e=this.field.leadingIcon,a=this.field.trailingIcon;if(!e&&!a)return t;let r=document.createElement("div");if(r.className="easy-form-input-wrapper",e&&this.isSlotContentValid(e)){let i=this.renderSlotContent(e);i.className="easy-form-input-slot easy-form-input-slot-leading",r.appendChild(i)}let s=document.createElement("div");if(s.className="easy-form-input-core",s.appendChild(t),r.appendChild(s),a&&this.isSlotContentValid(a)){let i=this.renderSlotContent(a);i.className="easy-form-input-slot easy-form-input-slot-trailing",r.appendChild(i)}return r}isSlotContentValid(t){return t.type?t.type==="image"?!!t.src:t.type==="html"?!!t.html:!1:!1}renderSlotContent(t){let e=document.createElement("span");if(e.className="easy-form-input-slot-content",t.type==="image"&&t.src){let a=document.createElement("img");a.src=t.src,a.alt=t.alt??"",a.setAttribute("aria-hidden","true"),e.appendChild(a)}else t.type==="html"&&t.html&&(e.innerHTML=t.html);return e}createFieldContainer(t){let e=document.createElement("div"),r=Array.from(t.classList).filter(d=>d.startsWith("easy-form-")&&d!=="easy-form-field"&&(d.includes("-container")||d.includes("-wrapper"))),s=this.field.labelPosition??"up",i=this.createInputWithSlots(t);if(r.length>0?e.className=`easy-form-field easy-form-label-${s} ${r.join(" ")}`:e.className=`easy-form-field easy-form-label-${s}`,s==="none"&&this.field.label){let d=i.querySelector("input, textarea, select")||i;d instanceof HTMLElement&&d.setAttribute("aria-label",this.field.label)}let n=(()=>{if(!this.field.label||s==="none")return null;let d=document.createElement("label");if(d.className="easy-form-label",d.setAttribute("for",this.getFieldId()),d.textContent=this.field.label,this.field.validations?.some(c=>c.type==="required")){let c=document.createElement("span");c.className="easy-form-required",c.textContent=" *",d.appendChild(c)}return d})();if(s==="up")n&&e.appendChild(n),e.appendChild(i);else if(s==="down")e.appendChild(i),n&&e.appendChild(n);else if(s==="left"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",n&&d.appendChild(n),d.appendChild(i),e.appendChild(d)}else if(s==="right"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",d.appendChild(i),n&&d.appendChild(n),e.appendChild(d)}else e.appendChild(i);if(this.field.description){let d=document.createElement("p");d.className="easy-form-description",d.textContent=this.field.description,e.appendChild(d)}if(this.error){let d=document.createElement("p");d.className="easy-form-error",d.textContent=this.error,e.appendChild(d)}return e}getFieldId(){return`easy-form-${this.field.name}`}applyCommonProps(t){if(t.id=this.getFieldId(),t.setAttribute("name",this.field.name),this.field.disabled&&(t.setAttribute("disabled","true"),t.classList.add("easy-form-input-disabled")),this.field.hidden&&(t.style.display="none",t.classList.add("easy-form-field-hidden")),this.error&&t.classList.add("easy-form-input-error"),this.field.props)for(let[e,a]of Object.entries(this.field.props))(e.startsWith("data-")||e.startsWith("aria-"))&&t.setAttribute(e,String(a))}};function xt(o){let t=[];for(let e=0;e<o.length;e++){let a=o[e];switch(a){case"9":t.push({type:"digit",char:"9",editable:!0});break;case"a":case"A":t.push({type:"letter",char:a,editable:!0});break;case"*":t.push({type:"any",char:"*",editable:!0});break;default:t.push({type:"literal",char:a,editable:!1});break}}return t}function G(o,t){let e="",a=0;for(let r of t){if(!r.editable){e+=r.char;continue}if(a>=o.length)break;let s=o[a];if(!(r.type==="digit"&&!/\d/.test(s))){{if(r.type==="letter"&&!/[a-zA-Z]/.test(s))continue;if(r.type!=="any"){if(r.type!=="any"&&r.type!=="digit"&&r.type!=="letter")continue}}e+=s,a++}}return e}function He(o,t){if(!o)return"";let e="",a=0;for(let r=0;r<o.length&&a<t.length;r++){let s=o[r],i=t[a];if(i.editable)i.type==="digit"&&/\d/.test(s)||i.type==="letter"&&/[a-zA-Z]/.test(s)||i.type==="any"?(e+=s,a++):(a++,r--);else if(s===i.char)a++;else if(a<t.length-1){let l=t[a+1];l&&l.editable&&(l.type==="digit"&&/\d/.test(s)||l.type==="letter"&&/[a-zA-Z]/.test(s)||l.type==="any")?(e+=s,a+=2):a++}else break}return e}function ae(o,t,e="forward"){if(e==="forward"){for(let a=o+1;a<t.length;a++)if(t[a].editable)return a;return t.length}else{for(let a=o-1;a>=0;a--)if(t[a].editable)return a;return 0}}function vt(o,t="_"){return o.map(e=>e.editable?t:e.char).join("")}function kt(o,t,e,a){let r=0;for(let i=0;i<Math.min(e,o.length);i++){let l=i;l<a.length&&a[l].editable&&r++}let s=0;for(let i=0;i<t.length&&i<a.length;i++)if(a[i].editable&&(s++,s>r))return i+1;return ae(Math.min(e,t.length-1),a,"forward")}var N=class{constructor(){this.tokenCache=new Map}getCustomMask(t){return t.custom?t.custom:t.type?Ve(t.type):null}getTokens(t){let e=this.getCustomMask(t);if(!e)return null;let a=e.pattern;if(this.tokenCache.has(a))return this.tokenCache.get(a);let r=xt(e.pattern);return this.tokenCache.set(a,r),r}applyMask(t,e){let a=this.getTokens(e);if(!a)return t;let r=this.getCustomMask(e),s=a.filter(d=>d.editable),i=new Set(s.map(d=>d.type)),l="";for(let d of t)(i.has("any")||i.has("digit")&&/\d/.test(d)||i.has("letter")&&/[a-zA-Z]/.test(d))&&(l+=d);let n=G(l,a);return r.transform&&(n=r.transform(n),n=G(n,a)),n}removeMask(t,e){let a=this.getTokens(e);return a?He(t,a):t}getMaskPlaceholder(t){let e=this.getTokens(t);if(!e)return"";let a=this.getCustomMask(t);return vt(e,a.placeholder||"_")}canInsertChar(t,e,a){let r=this.getTokens(a);if(!r||e>=r.length)return!1;let s=r[e];if(!s.editable)return!1;switch(s.type){case"digit":return/\d/.test(t);case"letter":return/[a-zA-Z]/.test(t);case"any":return!0;default:return!1}}processInput(t,e,a,r){let s=this.getTokens(a);if(!s)return{value:t,cursorPosition:t.length};let i=He(t,s),l=G(i,s),n=this.getCustomMask(a);n.transform&&(l=n.transform(l),l=G(l,s));let d=kt(e,l,r,s);return{value:l,cursorPosition:Math.min(d,l.length)}}processKeyInput(t,e,a,r,s=!1){let i=this.getTokens(r);if(!i)return{value:e,cursorPosition:a};if(s){if(a===0)return{value:e,cursorPosition:0};let l=ae(a-1,i,"backward"),n=e.substring(0,l),d=e.substring(a),c=n+d,m=this.removeMask(c,r),p=this.applyMask(m,r),u=Math.max(0,l-1),h=ae(u,i,"forward");return{value:p,cursorPosition:h}}if(t.length===1&&this.canInsertChar(t,a,r)){let l=e.substring(0,a),n=e.substring(a),d=l+t+n;return this.processInput(d,e,r,a)}return{value:e,cursorPosition:a}}};var se=class extends v{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new N)}render(){let e=document.createElement("input");e.type=this.field.type==="email"?"email":this.field.type==="password"?"password":"text";let a=this.value??"";if(this.maskEngine&&this.field.mask&&(a&&(a=this.maskEngine.applyMask(String(a),this.field.mask)),this.previousValue=a),e.value=a,this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,l=s.value,n=this.maskEngine.processInput(l,this.previousValue,this.field.mask,i);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=this.field.mask.keepFormat?n.value:this.maskEngine.removeMask(n.value,this.field.mask);this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let l=r.key==="Backspace",n=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,l);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=this.field.mask.keepFormat?n.value:this.maskEngine.removeMask(n.value,this.field.mask);this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,l=i.selectionStart||0,n=i.value.substring(0,l),d=i.value.substring(l),c=n+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,l);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=this.field.mask.keepFormat?m.value:this.maskEngine.removeMask(m.value,this.field.mask);this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target;this.onChange(s.value)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var ie=class extends v{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new N)}render(){let e=document.createElement("input");if(this.maskEngine&&this.field.mask){e.type="text";let r=this.value??"";r!==null&&r!==""&&(this.field.mask.type==="currency"?r=this.maskEngine.applyMask(String(r),this.field.mask):this.field.mask.type==="percentage"&&(r=this.maskEngine.applyMask(String(r),this.field.mask))),this.previousValue=r,e.value=r}else e.type="number",e.value=this.value??"";let a=this.field;if(!this.maskEngine&&e.type==="number"&&(a.min!==void 0&&(e.min=String(a.min)),a.max!==void 0&&(e.max=String(a.max)),a.step!==void 0&&(e.step=String(a.step))),this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,l=s.value,n=this.maskEngine.processInput(l,this.previousValue,this.field.mask,i);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let l=r.key==="Backspace",n=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,l);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,l=i.selectionStart||0,n=i.value.substring(0,l),d=i.value.substring(l),c=n+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,l);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=null;if(this.field.mask.type==="currency"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u):null}this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target,i=s.value===""?null:Number(s.value);this.onChange(i)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var oe=class extends v{render(){let t=document.createElement("textarea");t.value=this.value??"",t.placeholder=this.field.placeholder||"";let e=this.field;return e.rows&&(t.rows=e.rows),e.cols&&(t.cols=e.cols),this.applyCommonProps(t),t.addEventListener("input",a=>{let r=a.target;this.onChange(r.value)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ne=class extends v{render(){let t=document.createElement("select"),e=this.field;if(e.multiple&&(t.multiple=!0),!e.multiple){let r=document.createElement("option");r.value="",r.textContent=e.placeholder||"Selecciona una opci\xF3n",r.setAttribute("data-placeholder",""),r.disabled=!0,t.appendChild(r)}for(let r of e.options){let s=document.createElement("option");typeof r=="string"?(s.value=r,s.textContent=r):(s.value=String(r.value),s.textContent=r.label),t.appendChild(s)}if(e.multiple&&Array.isArray(this.value))for(let r of t.options)r.selected=this.value.includes(r.value);else t.value=this.value??"";this.applyCommonProps(t);let a=()=>{!t.value?t.classList.add("easy-form-select-placeholder"):t.classList.remove("easy-form-select-placeholder")};return a(),t.addEventListener("change",r=>{let s=r.target;if(a(),e.multiple){let i=Array.from(s.selectedOptions).map(l=>l.value);this.onChange(i)}else this.onChange(s.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var le=class extends v{render(){let t=document.createElement("input");t.type="checkbox",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-checkbox",a.setAttribute("for",this.getFieldId()),a.appendChild(t),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var de=class extends v{render(){let t=document.createElement("div");if(t.className="easy-form-field",this.field.label){let r=document.createElement("label");if(r.className="easy-form-label",r.textContent=this.field.label,this.field.validations?.some(s=>s.type==="required")){let s=document.createElement("span");s.className="easy-form-required",s.textContent=" *",r.appendChild(s)}t.appendChild(r)}let e=document.createElement("div");e.className="easy-form-radio-group";let a=this.field;for(let r of a.options){let s=typeof r=="string"?r:r.value,i=typeof r=="string"?r:r.label,l=document.createElement("div");l.className="easy-form-radio-option";let n=document.createElement("input");n.type="radio",n.name=this.field.name,n.id=`${this.getFieldId()}-${s}`,n.value=String(s),n.checked=String(this.value)===String(s),this.field.disabled&&(n.disabled=!0);let d=document.createElement("label");d.setAttribute("for",n.id),d.textContent=i,d.className="easy-form-radio-label",n.addEventListener("change",()=>{this.onChange(s)}),n.addEventListener("blur",()=>{this.onBlur()}),l.appendChild(n),l.appendChild(d),e.appendChild(l)}if(t.appendChild(e),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,t.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,t.appendChild(r)}return t}};var ce=class extends v{render(){let t=document.createElement("input");t.type="checkbox",t.className="easy-form-switch",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-switch",a.setAttribute("for",this.getFieldId()),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(a.appendChild(t),e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var pe=class extends v{render(){let t=document.createElement("input");t.type="date";let e=this.field;if(e.min&&(t.min=e.min),e.max&&(t.max=e.max),this.value){let a=this.value instanceof Date?this.value.toISOString().split("T")[0]:String(this.value);t.value=a}return this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;this.onChange(r.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var me=class extends v{render(){let t=document.createElement("input");t.type="file";let e=this.field;return e.accept&&(t.accept=e.accept),e.multiple&&(t.multiple=!0),this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;r.files&&(e.multiple?this.onChange(Array.from(r.files)):this.onChange(r.files[0]||null))}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ue=class extends v{render(){let t=document.createElement("div");t.className="easy-form-quantity-container";let e=this.field,a=e.min??0,r=e.max??void 0,s=e.step??1,i=this.value??a,l=document.createElement("div");l.className="easy-form-quantity-wrapper";let n=document.createElement("button");n.type="button",n.className="easy-form-quantity-btn easy-form-quantity-decrement",n.textContent="\u2212",n.setAttribute("aria-label","Decrementar"),i<=a&&(n.disabled=!0,n.classList.add("disabled"));let d=document.createElement("input");d.type="number",d.value=String(i),d.min=String(a),r!==void 0&&(d.max=String(r)),d.step=String(s),d.className="easy-form-quantity-input",this.applyCommonProps(d);let c=document.createElement("button");c.type="button",c.className="easy-form-quantity-btn easy-form-quantity-increment",c.textContent="+",c.setAttribute("aria-label","Incrementar"),r!==void 0&&i>=r&&(c.disabled=!0,c.classList.add("disabled")),n.addEventListener("click",()=>{let p=Math.max(a,Number(d.value)-s);d.value=String(p),this.onChange(p),m()}),c.addEventListener("click",()=>{let p=r!==void 0?Math.min(r,Number(d.value)+s):Number(d.value)+s;d.value=String(p),this.onChange(p),m()}),d.addEventListener("input",p=>{let u=p.target,h=Number(u.value);isNaN(h)&&(h=a),h<a&&(h=a),r!==void 0&&h>r&&(h=r),u.value=String(h),this.onChange(h),m()}),d.addEventListener("blur",()=>{this.onBlur()});let m=()=>{let p=Number(d.value);n.disabled=p<=a,n.classList.toggle("disabled",p<=a),r!==void 0?(c.disabled=p>=r,c.classList.toggle("disabled",p>=r)):(c.disabled=!1,c.classList.remove("disabled"))};return l.appendChild(n),l.appendChild(d),l.appendChild(c),t.appendChild(l),this.createFieldContainer(t)}};var fe=class extends v{constructor(){super(...arguments);this.openAccordion=null}render(){let e=document.createElement("div");e.className="easy-form-accordion-select-container";let a=this.field,r=this.value??null;return a.options.forEach((s,i)=>{let l=typeof s=="string"?s:s.value,n=typeof s=="string"?s:s.label,d=typeof s=="object"&&"description"in s&&s.description?s.description:void 0,c=document.createElement("div");c.className="easy-form-accordion-item",c.setAttribute("data-value",String(l)),(r===l||Array.isArray(r)&&r.includes(l))&&(c.classList.add("selected"),a.multiple||(this.openAccordion=String(l)));let m=document.createElement("div");m.className="easy-form-accordion-header",m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-expanded","false");let p=document.createElement("div");p.className="easy-form-accordion-header-content";let u=document.createElement("div");u.className="easy-form-accordion-indicator",a.multiple?(u.classList.add("checkbox"),Array.isArray(r)&&r.includes(l)&&u.classList.add("checked")):(u.classList.add("radio"),r===l&&u.classList.add("checked"));let h=document.createElement("span");h.className="easy-form-accordion-label",h.textContent=n;let g=document.createElement("span");g.className="easy-form-accordion-arrow",g.textContent="\u25BC",p.appendChild(u),p.appendChild(h),m.appendChild(p),m.appendChild(g);let f=document.createElement("div");if(f.className="easy-form-accordion-content",d){let b=document.createElement("p");b.className="easy-form-accordion-description",b.textContent=d,f.appendChild(b)}if(typeof s=="object"&&"content"in s&&s.content){let b=document.createElement("div");b.className="easy-form-accordion-custom-content",typeof s.content=="string"?b.innerHTML=s.content:s.content instanceof HTMLElement&&b.appendChild(s.content),f.appendChild(b)}c.appendChild(m),c.appendChild(f);let y=()=>{let b=c.classList.contains("open");a.multiple||e.querySelectorAll(".easy-form-accordion-item").forEach(w=>{if(w!==c){w.classList.remove("open");let S=w.querySelector(".easy-form-accordion-header"),k=w.querySelector(".easy-form-accordion-content"),F=w.querySelector(".easy-form-accordion-arrow");S&&S.setAttribute("aria-expanded","false"),k&&(k.style.maxHeight=null),F&&(F.style.transform="rotate(0deg)")}}),b?(c.classList.remove("open"),m.setAttribute("aria-expanded","false"),f.style.maxHeight=null,g.style.transform="rotate(0deg)",this.openAccordion=null):(c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)",this.openAccordion=String(l))},x=()=>{if(a.multiple){let b=Array.isArray(r)?[...r]:[],w=b.indexOf(l);w>-1?(b.splice(w,1),c.classList.remove("selected"),u.classList.remove("checked")):(b.push(l),c.classList.add("selected"),u.classList.add("checked")),this.onChange(b.length>0?b:null)}else e.querySelectorAll(".easy-form-accordion-item").forEach(b=>{b.classList.remove("selected");let w=b.querySelector(".easy-form-accordion-indicator");w&&w.classList.remove("checked")}),c.classList.add("selected"),u.classList.add("checked"),this.onChange(l)};m.addEventListener("click",b=>{b.stopPropagation(),x(),y()}),m.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x(),y())}),(r===l||Array.isArray(r)&&r.includes(l))&&(!a.multiple||a.autoExpand)&&setTimeout(()=>{c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)"},0),e.appendChild(c)}),this.createFieldContainer(e)}};var he=class extends v{render(){let t=document.createElement("div");t.className="easy-form-image-grid-container";let e=this.field,a=this.value??null,r=e.columns??3,s=e.imageSize??"medium";return t.style.gridTemplateColumns=`repeat(${r}, 1fr)`,t.style.gap=e.gap??"1rem",e.options.forEach(i=>{let l=typeof i=="string"?i:i.value,n=typeof i=="string"?i:i.label,d=typeof i=="object"&&"image"in i&&i.image?i.image:void 0,c=typeof i=="object"&&"description"in i&&i.description?i.description:void 0,m=document.createElement("div");m.className=`easy-form-image-grid-item easy-form-image-grid-${s}`,m.setAttribute("data-value",String(l)),m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-label",n),(a===l||Array.isArray(a)&&a.includes(l))&&m.classList.add("selected");let p=document.createElement("div");if(p.className="easy-form-image-grid-image-container",d){let f=document.createElement("img");f.src=d,f.alt=n,f.className="easy-form-image-grid-image",p.appendChild(f)}else{let f=document.createElement("div");f.className="easy-form-image-grid-placeholder",f.textContent=n.charAt(0).toUpperCase(),p.appendChild(f)}let u=document.createElement("div");u.className="easy-form-image-grid-indicator",e.multiple?(u.classList.add("checkbox"),Array.isArray(a)&&a.includes(l)&&(u.classList.add("checked"),u.innerHTML="\u2713")):(u.classList.add("radio"),a===l&&(u.classList.add("checked"),u.innerHTML="\u25CF")),p.appendChild(u);let h=document.createElement("div");if(h.className="easy-form-image-grid-label",h.textContent=n,c){let f=document.createElement("div");f.className="easy-form-image-grid-description",f.textContent=c,m.appendChild(f)}m.appendChild(p),m.appendChild(h);let g=()=>{if(e.multiple){let f=Array.isArray(a)?[...a]:[],y=f.indexOf(l);y>-1?(f.splice(y,1),m.classList.remove("selected"),u.classList.remove("checked"),u.innerHTML=""):(f.push(l),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u2713"),this.onChange(f.length>0?f:null)}else t.querySelectorAll(".easy-form-image-grid-item").forEach(f=>{f.classList.remove("selected");let y=f.querySelector(".easy-form-image-grid-indicator");y&&(y.classList.remove("checked"),y.innerHTML="")}),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u25CF",this.onChange(l)};m.addEventListener("click",g),m.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),g())}),m.addEventListener("blur",()=>{this.onBlur()}),t.appendChild(m)}),this.createFieldContainer(t)}};var ge=class extends v{constructor(){super(...arguments);this.inputs=[]}render(){let e=document.createElement("div");e.className="easy-form-otp-container";let r=this.field.length??6,s=this.value??"",i=String(s).padStart(r,"").slice(0,r);for(let l=0;l<r;l++){let n=document.createElement("input");n.type="text",n.inputMode="numeric",n.maxLength=1,n.className="easy-form-otp-input",n.setAttribute("aria-label",`C\xF3digo d\xEDgito ${l+1}`),i[l]&&(n.value=i[l]),this.applyCommonProps(n),n.id=`${this.getFieldId()}-${l}`;let d=l;n.addEventListener("input",c=>{let m=c.target,p=m.value.replace(/[^0-9]/g,"");m.value=p,p&&d<r-1&&this.inputs[d+1].focus(),this.updateOTPValue()}),n.addEventListener("keydown",c=>{let m=c.target;c.key==="Backspace"&&!m.value&&d>0&&(this.inputs[d-1].focus(),this.inputs[d-1].value="",this.updateOTPValue()),c.key==="ArrowLeft"&&d>0&&(c.preventDefault(),this.inputs[d-1].focus()),c.key==="ArrowRight"&&d<r-1&&(c.preventDefault(),this.inputs[d+1].focus())}),n.addEventListener("paste",c=>{c.preventDefault();let p=(c.clipboardData||window.clipboardData).getData("text").replace(/[^0-9]/g,"").slice(0,r);for(let h=0;h<p.length&&d+h<r;h++)this.inputs[d+h].value=p[h];let u=Math.min(d+p.length,r-1);this.inputs[u].focus(),this.updateOTPValue()}),n.addEventListener("focus",c=>{c.target.select()}),n.addEventListener("blur",()=>{this.onBlur()}),this.inputs.push(n),e.appendChild(n)}return this.createFieldContainer(e)}updateOTPValue(){let e=this.inputs.map(s=>s.value).join(""),a=this.field,r=e.length===this.inputs.length?e:null;a.numeric&&r?this.onChange(Number(r)):this.onChange(r)}};var Qt=6;function be(o){return o?'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'}var ye=class extends v{constructor(){super(...arguments);this.inputs=[];this.visible=!1}get passwordField(){return this.field}render(){let e=this.passwordField,a=!!e.characterSeparated,r=a?typeof e.characterSeparated=="number"?e.characterSeparated:Qt:0;return a?this.createFieldContainer(this.renderSeparated(r)):this.createFieldContainer(this.renderSingle())}renderSingle(){let a=!!this.passwordField.showToggle,r=document.createElement("input");if(r.type="password",r.value=this.value??"",r.id=this.getFieldId(),this.applyCommonProps(r),this.field.placeholder&&(r.placeholder=this.field.placeholder),r.addEventListener("input",l=>{this.onChange(l.target.value)}),r.addEventListener("blur",()=>this.onBlur()),!a)return r;let s=document.createElement("div");s.className="easy-form-password-inner",r.classList.add("easy-form-password-input"),s.appendChild(r);let i=document.createElement("button");return i.type="button",i.className="easy-form-password-toggle",i.setAttribute("aria-label","Mostrar contrase\xF1a"),i.innerHTML=be(!1),i.addEventListener("click",()=>{this.visible=!this.visible,r.type=this.visible?"text":"password",i.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),i.innerHTML=be(this.visible)}),s.appendChild(i),s}renderSeparated(e){let r=!!this.passwordField.showToggle,s=this.value??"",i=String(s).slice(0,e),l=document.createElement("div");l.className="easy-form-password-separated";for(let n=0;n<e;n++){let d=document.createElement("input");d.type="password",d.maxLength=1,d.className="easy-form-password-separated-input",d.setAttribute("aria-label",`Car\xE1cter ${n+1} de ${e}`),i[n]&&(d.value=i[n]),this.applyCommonProps(d),d.id=n===0?this.getFieldId():`${this.getFieldId()}-${n}`,n>0&&d.removeAttribute("name");let c=n;d.addEventListener("input",m=>{m.target.value&&c<e-1&&this.inputs[c+1].focus(),this.updateSeparatedValue()}),d.addEventListener("keydown",m=>{m.key==="Backspace"&&!m.target.value&&c>0&&(this.inputs[c-1].focus(),this.inputs[c-1].value="",this.updateSeparatedValue()),m.key==="ArrowLeft"&&c>0&&(m.preventDefault(),this.inputs[c-1].focus()),m.key==="ArrowRight"&&c<e-1&&(m.preventDefault(),this.inputs[c+1].focus())}),d.addEventListener("paste",m=>{m.preventDefault();let u=((m.clipboardData||window.clipboardData)?.getData("text")||"").slice(0,e-c).split("");for(let g=0;g<u.length&&c+g<e;g++)this.inputs[c+g].value=u[g];let h=Math.min(c+u.length,e-1);this.inputs[h].focus(),this.updateSeparatedValue()}),d.addEventListener("focus",m=>m.target.select()),d.addEventListener("blur",()=>this.onBlur()),this.inputs.push(d),l.appendChild(d)}if(r){let n=document.createElement("div");n.className="easy-form-password-separated-toggle";let d=document.createElement("button");d.type="button",d.className="easy-form-password-toggle",d.setAttribute("aria-label","Mostrar contrase\xF1a"),d.innerHTML=be(!1),d.addEventListener("click",()=>{this.visible=!this.visible;let c=this.visible?"text":"password";this.inputs.forEach(m=>{m.type=c}),d.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),d.innerHTML=be(this.visible)}),n.appendChild(d),l.appendChild(n)}return l}updateSeparatedValue(){let e=this.inputs.map(a=>a.value).join("");this.onChange(e||null)}};var xe=class extends v{render(){let t=this.field,e=t.accept??"",a=t.multiple??!1,r=document.createElement("div");r.className="easy-form-file-drop",r.setAttribute("tabindex","0");let s=document.createElement("input");s.type="file",s.className="easy-form-file-drop-input",s.style.display="none",e&&(s.accept=e),a&&(s.multiple=!0);let i=document.createElement("span");i.className="easy-form-file-drop-label",i.textContent="Arrastra archivos aqu\xED o haz clic para seleccionar",r.appendChild(i),r.appendChild(s);let l=document.createElement("div");l.className="easy-form-file-drop-list";let n=c=>{let m=c?Array.isArray(c)?c.map(p=>p.name):[c.name]:[];if(l.innerHTML="",m.length===0){l.style.display="none";return}l.style.display="block",m.forEach(p=>{let u=document.createElement("div");u.className="easy-form-file-drop-item",u.textContent=p,l.appendChild(u)})};n(this.value);let d=c=>{if(!c||c.length===0)return;let m=a?Array.from(c):c[0];this.onChange(m),this.onBlur(),n(m)};return r.addEventListener("click",()=>{s.click()}),s.addEventListener("change",c=>{let m=c.target;d(m.files),m.value=""}),r.addEventListener("dragover",c=>{c.preventDefault(),c.stopPropagation(),r.classList.add("easy-form-file-drop-over")}),r.addEventListener("dragleave",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over")}),r.addEventListener("drop",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over"),d(c.dataTransfer?.files??null)}),r.appendChild(l),this.createFieldContainer(r)}};var Jt="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",ve=class extends v{constructor(){super(...arguments);this.mapInstance=null;this.markerInstance=null}render(){let e=this.field,a=e.center??{lat:0,lng:0},r=e.zoom??13,s=this.value,i=typeof s=="object"&&s?.lat!=null?s.lat:a.lat,l=typeof s=="object"&&s?.lng!=null?s.lng:a.lng,n=document.createElement("div");n.className="easy-form-map";let d=document.createElement("div");d.className="easy-form-map-inputs";let c=document.createElement("input");c.type="number",c.step="any",c.placeholder="Latitud",c.value=String(i),c.className="easy-form-map-lat";let m=document.createElement("input");m.type="number",m.step="any",m.placeholder="Longitud",m.value=String(l),m.className="easy-form-map-lng";let p=()=>{let x=parseFloat(c.value),b=parseFloat(m.value);!isNaN(x)&&!isNaN(b)&&(this.onChange({lat:x,lng:b}),this.syncMarkerPosition(x,b)),this.onBlur()};c.addEventListener("change",p),m.addEventListener("change",p),d.appendChild(c),d.appendChild(m),n.appendChild(d);let u=document.createElement("div");u.className="easy-form-map-container",n.appendChild(u);let h="easy-form-leaflet-css",g=!1,f=document.createElement("link");return f.id=h,f.rel="stylesheet",f.href=Jt,f.onload=()=>{g=!0},n.insertBefore(f,n.firstChild),(async()=>{if(typeof window>"u")return;u.style.height="300px",u.style.width="100%",u.style.position="relative",u.style.overflow="hidden",u.style.display="block",await new Promise(k=>{let F=()=>{g&&u.offsetWidth>0&&u.offsetHeight>0?k(void 0):requestAnimationFrame(F)};F()}),await new Promise(k=>setTimeout(k,50));let x;try{x=await import("leaflet")}catch{u.innerHTML=`
|
|
2654
|
+
`}function te(o,t){let e=st(t),a=Gt(o,t);return e+a}function Gt(o,t){switch(o){case"plano":return De(t);case"tradicional":return it(t);case"material":return ot(t);case"rounded-shadow":return nt(t);case"lines":return lt(t);case"shadcn":return dt(t);case"chakra":return ct(t);case"mantine":return pt(t);case"glass":return mt(t);case"bordered":return ut(t);case"minimal":return ft(t);case"efc":return ht(t);default:return De(t)}}var gt={phone:{pattern:"(999) 999-9999",placeholder:"_"},"phone-us":{pattern:"(999) 999-9999",placeholder:"_"},"phone-international":{pattern:"+99 999 999 9999",placeholder:"_"},date:{pattern:"99/99/9999",placeholder:"_"},"date-us":{pattern:"99/99/9999",placeholder:"_"},"date-eu":{pattern:"99-99-9999",placeholder:"_"},"credit-card":{pattern:"9999 9999 9999 9999",placeholder:"_"},ssn:{pattern:"999-99-9999",placeholder:"_"},"zip-code":{pattern:"99999",placeholder:"_"},currency:{pattern:"$999,999.99",placeholder:"_",transform:o=>{let t=o.replace(/[^\d.]/g,"");return(parseFloat(t)||0).toFixed(2)}},percentage:{pattern:"999%",placeholder:"_",transform:o=>o.replace(/[^\d]/g,"")},time:{pattern:"99:99",placeholder:"_"},datetime:{pattern:"99/99/9999 99:99",placeholder:"_"}};function Ve(o){return gt[o]}var re="El valor contiene caracteres o patrones no permitidos",Kt=[/\b(union|select|insert|update|delete|drop|exec|execute|declare)\s+(all\s+)?(select|from|into|table)/i,/\b(or|and)\s+['"]?\d+['"]?\s*=\s*['"]?\d+/i,/;\s*(drop|delete|truncate|alter)\s+/i,/--\s*$/,/\/\*[\s\S]*\*\//,/'\s*or\s+'1'\s*=\s*'1/i,/"\s*or\s+"1"\s*=\s*"1/i,/\bexec\s*\(/i,/\bxp_\w+/i,/<script\b[\s\S]*?>[\s\S]*?<\/script>/i,/<script\b/i,/javascript\s*:/i,/vbscript\s*:/i,/on\w+\s*=\s*["'][^"']*["']/i,/on\w+\s*=\s*[^\s>]+/i,/<iframe\b/i,/<object\b/i,/<embed\b/i,/\beval\s*\(/i,/document\.(cookie|write|location)/i,/window\.(location|open|eval)/i,/[;&|]\s*(ls|cat|rm|wget|curl|nc|bash|sh|python|perl)\s/i,/\$\s*\([^)]+\)/,/`[^`]+`/,/\|\s*\w+/,/\$\s*where\b/i,/\$\s*gt\b|\$\s*ne\b|\$\s*regex\b/i,/\{\{[^}]*\}\}/,/\$\{[^}]*\}/];function bt(o){if(typeof o!="string"||o.length===0||o.trim().length===0)return!1;for(let e of Kt)if(e.test(o))return!0;return!1}function W(o){return o==null?!0:typeof o=="string"?!bt(o):Array.isArray(o)?o.every(t=>W(t)):typeof o=="object"?Object.values(o).every(t=>W(t)):!0}var U=class{constructor(t){this.attempts=0;this.lockedUntil=null;this.unlockCheckInterval=null;this.maxAttempts=Math.max(1,t.maxAttempts),this.blockDurationMs=(t.blockDurationMinutes??5)*60*1e3,this.storageKey=t.storageKey,this.onLocked=t.onLocked,this.onUnlocked=t.onUnlocked,this.storageKey&&typeof sessionStorage<"u"&&this.loadFromStorage()}loadFromStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t=sessionStorage.getItem(this.storageKey);if(t){let e=JSON.parse(t);this.attempts=e.attempts??0,this.lockedUntil=e.lockedUntil??null,this.checkExpiration()}}catch{}}saveToStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t={attempts:this.attempts,lockedUntil:this.lockedUntil??void 0};sessionStorage.setItem(this.storageKey,JSON.stringify(t))}catch{}}checkExpiration(){return this.lockedUntil===null?!1:Date.now()>=this.lockedUntil?(this.reset(),this.onUnlocked?.(),!0):!1}startUnlockCheck(){this.unlockCheckInterval||(this.unlockCheckInterval=setInterval(()=>{this.checkExpiration()&&this.stopUnlockCheck()},1e3))}stopUnlockCheck(){this.unlockCheckInterval&&(clearInterval(this.unlockCheckInterval),this.unlockCheckInterval=null)}incrementAttempts(){this.attempts++,this.attempts>=this.maxAttempts?(this.lockedUntil=Date.now()+this.blockDurationMs,this.saveToStorage(),this.onLocked?.(this.blockDurationMs),this.startUnlockCheck()):this.saveToStorage()}isLocked(){return this.checkExpiration()?!1:this.lockedUntil!==null&&Date.now()<this.lockedUntil}getRemainingBlockTimeMs(){return this.checkExpiration()||this.lockedUntil===null?0:Math.max(0,this.lockedUntil-Date.now())}reset(){this.attempts=0,this.lockedUntil=null,this.stopUnlockCheck(),this.saveToStorage()}getAttempts(){return this.attempts}};function H(o){return o==null?"":typeof o=="boolean"?o?"true":"false":typeof o=="object"?JSON.stringify(o):String(o)}function q(o){if(!o)return null;try{return JSON.parse(o)}catch{return o}}function Wa(o="ef"){return`${o}-${Math.random().toString(36).substr(2,9)}`}function I(o,t){return t.split(".").reduce((e,a)=>e?.[a],o)}function B(o,t,e){let a=t.split("."),r=a.pop(),s=a.reduce((i,l)=>((!i[l]||typeof i[l]!="object")&&(i[l]={}),i[l]),o);s[r]=e}function yt(o){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)}function Ua(o){return o.replace(/[^a-zA-Z0-9-_]/g,"-")}var P=class{evaluateCondition(t,e){let a=this.getFieldValue(t.field,e);return this.compareValues(a,t.operator,t.value)}evaluateConditions(t,e,a="and"){let r=Array.isArray(t)?t:[t];return r.length===0?!0:a==="and"?r.every(s=>this.evaluateCondition(s,e)):r.some(s=>this.evaluateCondition(s,e))}evaluateDependencies(t,e){let a=!0,r=!0,s=!1;if(t.show&&(a=this.evaluateConditions(t.show,e)),t.hide){let i=this.evaluateConditions(t.hide,e);a=a&&!i}if(t.enable&&(r=this.evaluateConditions(t.enable,e)),t.disable){let i=this.evaluateConditions(t.disable,e);r=r&&!i}if(t.required&&(s=this.evaluateConditions(t.required,e)),t.optional){let i=this.evaluateConditions(t.optional,e);s=s&&!i}return{visible:a,enabled:r,required:s}}getFieldValue(t,e){if(t in e)return e[t];let a=t.split("."),r=e;for(let s of a){if(r==null)return null;r=r[s]}return r}compareValues(t,e,a){switch(e){case"equals":return this.deepEqual(t,a);case"notEquals":return!this.deepEqual(t,a);case"contains":return Array.isArray(t)?t.includes(a):typeof t=="string"?t.includes(String(a)):!1;case"notContains":return!this.compareValues(t,"contains",a);case"greaterThan":return this.toNumber(t)>this.toNumber(a);case"lessThan":return this.toNumber(t)<this.toNumber(a);case"greaterThanOrEqual":return this.toNumber(t)>=this.toNumber(a);case"lessThanOrEqual":return this.toNumber(t)<=this.toNumber(a);case"in":return Array.isArray(a)?a.includes(t):!1;case"notIn":return!this.compareValues(t,"in",a);case"isEmpty":return t==null||t===""||Array.isArray(t)&&t.length===0;case"isNotEmpty":return!this.compareValues(t,"isEmpty",a);case"regex":try{return(typeof a=="string"?new RegExp(a):a).test(String(t||""))}catch{return!1}default:return!1}}deepEqual(t,e){if(t===e)return!0;if(t===null||e===null||t===void 0||e===void 0)return t===e;if(typeof t!=typeof e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((a,r)=>this.deepEqual(a,e[r]));if(typeof t=="object"){let a=Object.keys(t),r=Object.keys(e);return a.length!==r.length?!1:a.every(s=>this.deepEqual(t[s],e[s]))}return!1}toNumber(t){if(typeof t=="number")return t;if(typeof t=="string"){let e=parseFloat(t);return isNaN(e)?0:e}return 0}};var Y=class{constructor(){this.conditionEngine=new P}async validateField(t,e){return this.validateFieldWithValidations(t,e,t.validations||[])}async validateFieldWithValidations(t,e,a){let r=[];if(!a||a.length===0)return r;for(let s of a){let i=await this.validateValue(s,e);i.isValid||r.push(i.message||this.getDefaultMessage(s))}return r}async validateValue(t,e){switch(t.type){case"required":return this.validateRequired(e);case"email":return this.validateEmail(e);case"minLength":return this.validateMinLength(e,t.value);case"maxLength":return this.validateMaxLength(e,t.value);case"min":return this.validateMin(e,t.value);case"max":return this.validateMax(e,t.value);case"pattern":return this.validatePattern(e,t.value);case"custom":return await this.validateCustom(e,t);case"noInjection":return this.validateNoInjection(e,t);default:return{isValid:!0}}}validateRequired(t){let e=t!=null&&t!==""&&!(Array.isArray(t)&&t.length===0);return{isValid:e,message:e?void 0:"Este campo es requerido"}}validateEmail(t){if(!t)return{isValid:!0};let e=typeof t=="string"&&yt(t);return{isValid:e,message:e?void 0:"Debe ser un email v\xE1lido"}}validateMinLength(t,e){if(!t)return{isValid:!0};let r=String(t).length>=e;return{isValid:r,message:r?void 0:`Debe tener al menos ${e} caracteres`}}validateMaxLength(t,e){if(!t)return{isValid:!0};let r=String(t).length<=e;return{isValid:r,message:r?void 0:`Debe tener m\xE1ximo ${e} caracteres`}}validateMin(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a>=e;return{isValid:r,message:r?void 0:`Debe ser mayor o igual a ${e}`}}validateMax(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a<=e;return{isValid:r,message:r?void 0:`Debe ser menor o igual a ${e}`}}validatePattern(t,e){if(!t)return{isValid:!0};let a;if(e instanceof RegExp)a=e;else if(typeof e=="string")try{a=new RegExp(e)}catch{return console.warn("Invalid regex pattern:",e),{isValid:!0}}else return console.warn("Pattern validation expects string or RegExp, got:",typeof e,e),{isValid:!0};let r=a.test(String(t));return{isValid:r,message:r?void 0:"El formato no es v\xE1lido"}}validateNoInjection(t,e){if(t==null||t==="")return{isValid:!0};let a=W(t);return{isValid:a,message:a?void 0:e.message||re}}async validateCustom(t,e){try{let a=await e.validator(t);return{isValid:!!a,message:a?void 0:e.message||"Validaci\xF3n fallida"}}catch{return{isValid:!1,message:e.message||"Error en la validaci\xF3n"}}}getDefaultMessage(t){switch(t.type){case"required":return"Este campo es requerido";case"email":return"Debe ser un email v\xE1lido";case"minLength":return`Debe tener al menos ${t.value} caracteres`;case"maxLength":return`Debe tener m\xE1ximo ${t.value} caracteres`;case"min":return`Debe ser mayor o igual a ${t.value}`;case"max":return`Debe ser menor o igual a ${t.value}`;case"pattern":return"El formato no es v\xE1lido";case"custom":return"Validaci\xF3n fallida";case"noInjection":return re;default:return"Campo inv\xE1lido"}}shouldValidateField(t,e){if(t.hidden||t.disabled)return!1;if(t.dependencies){let a=this.conditionEngine.evaluateDependencies(t.dependencies,e);if(!a.visible||!a.enabled)return!1}return!0}async validateForm(t,e){let a={};for(let r of t)if(this.shouldValidateField(r,e))if(r.type==="array"&&"itemSchema"in r){let l=r.itemSchema?.fields||[],n=e[r.name];if(Array.isArray(n))for(let c=0;c<n.length;c++){let m=n[c];for(let p of l){let u=`${r.name}.${c}.${p.name}`,h=m?.[p.name];if(!this.shouldValidateField(p,e))continue;let g=await this.validateField(p,h);g.length>0&&(a[u]=g)}}let d=await this.validateArrayField(r,n);d.length>0&&(a[r.name]=d)}else{let s=e[r.name],i=await this.validateField(r,s);i.length>0&&(a[r.name]=i)}return a}async validateArrayField(t,e){let a=[],r=t;return r.minItems!==void 0&&(Array.isArray(e)&&e.length>=r.minItems||a.push(`Debe tener al menos ${r.minItems} elementos`)),r.maxItems!==void 0&&(Array.isArray(e)&&e.length<=r.maxItems||a.push(`Debe tener m\xE1ximo ${r.maxItems} elementos`)),a}};var Z=class{constructor(){this.wizardState=null;this.schema=null;this.dependencyCache=new Map;this.fieldDependencies=new Map;this.parser=new O,this.validator=new Y,this.conditionEngine=new P,this.state=this.createInitialState()}createInitialState(){return{values:{},errors:{},touched:{},isValid:!0,isSubmitting:!1}}initializeSchema(t,e){this.schema=this.parser.parse(t),this.initializeValues(e),this.initializeWizard(),this.buildDependencyMap()}extractAllFields(t){let e=[];for(let a of t)e.push(a),a.type==="group"&&"fields"in a&&e.push(...this.extractAllFields(a.fields)),a.type==="row"&&"fields"in a&&e.push(...this.extractAllFields(a.fields));return e}getArrayItemOnlyFieldNames(t){let e=new Set(t.map(r=>r.name)),a=new Set;for(let r of t)if(r.type==="array"&&"itemSchema"in r&&r.itemSchema?.fields)for(let s of r.itemSchema.fields)e.has(s.name)||a.add(s.name);return a}extractAllFieldsWithArrays(t,e="",a="root"){let r=[];for(let s of t){let i=e?`${e}.${s.name}`:s.name,l=e||"";r.push({field:s,fullPath:i,containerType:a,containerPath:l}),s.type==="group"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"group")),s.type==="row"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"row")),s.type==="array"&&"itemSchema"in s&&s.itemSchema?.fields&&r.push(...this.extractAllFieldsWithArrays(s.itemSchema.fields,s.name,"array"))}return r}buildDependencyMap(){if(this.fieldDependencies.clear(),this.dependencyCache.clear(),!this.schema)return;let t=this.schema.isWizard?this.schema.steps.flatMap(a=>a.fields):this.schema.fields||[],e=this.extractAllFieldsWithArrays(t);for(let{field:a,fullPath:r,containerType:s,containerPath:i}of e){if(!a.dependencies)continue;let l=this.extractObservedFields(a.dependencies);for(let n of l)this.fieldDependencies.has(n)||this.fieldDependencies.set(n,new Set),this.fieldDependencies.get(n).add(a.name),r!==a.name&&this.fieldDependencies.get(n).add(r),s==="array"&&i&&(this.fieldDependencies.has(i)||this.fieldDependencies.set(i,new Set),this.fieldDependencies.get(i).add(r))}}extractObservedFields(t){let e=new Set,a=s=>{s&&s.field&&e.add(s.field)},r=s=>{Array.isArray(s)?s.forEach(a):s&&a(s)};return t.show&&r(t.show),t.hide&&r(t.hide),t.enable&&r(t.enable),t.disable&&r(t.disable),t.required&&r(t.required),t.optional&&r(t.optional),e}initializeValues(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(l=>l.fields):this.schema.fields||[],a=this.extractAllFields(e),r={...this.state.values},s={};if(t)for(let l in t){let n=t[l];n!=null&&B(s,l,n)}for(let l of a){let n=I(s,l.name);if(n!=null)continue;let d=I(r,l.name);d!=null?B(s,l.name,d):this.initializeFieldValue(l,s)}let i=this.getArrayItemOnlyFieldNames(e);for(let l in r)i.has(l)||l in s||(s[l]=r[l]);for(let l of e)if(l.type==="array"&&"minItems"in l&&"itemSchema"in l){let n=l,d=n.minItems??0;if(d>=1&&n.itemSchema?.fields?.length){let c=I(s,l.name);if(Array.isArray(c)&&c.length<d){let m=[...c];for(let p=c.length;p<d;p++){let u={};for(let h of n.itemSchema.fields)this.initializeFieldValue(h,u);m.push(u)}B(s,l.name,m)}}}for(let l of i)l in s&&delete s[l];this.state.values=s}initializeFieldValue(t,e){if(t.defaultValue!==void 0)e[t.name]=t.defaultValue;else switch(t.type){case"checkbox":case"switch":e[t.name]=t.checked||!1;break;case"select":"multiple"in t&&t.multiple?e[t.name]=[]:e[t.name]=null;break;case"array":{let a=t,r=a.minItems??0,s=a.itemSchema?.fields;if(r>=1&&s?.length){let i=[];for(let l=0;l<r;l++){let n={};for(let d of s)this.initializeFieldValue(d,n);i.push(n)}e[t.name]=i}else e[t.name]=[];break}case"group":if(e[t.name]={},"fields"in t)for(let a of t.fields)this.initializeFieldValue(a,e[t.name]);break;case"colorpicker":e[t.name]=t.defaultValue??"#000000";break;default:e[t.name]=null}}initializeWizard(){if(!this.schema||!this.schema.isWizard){this.wizardState=null;return}this.wizardState={currentStep:0,totalSteps:this.schema.steps.length,completedSteps:[]}}getState(){return{...this.state}}getWizardState(){return this.wizardState?{...this.wizardState}:null}getValue(t){return I(this.state.values,t)}createDefaultArrayItem(t){let a=t.itemSchema?.fields;if(!a?.length)return{};let r={};for(let s of a)this.initializeFieldValue(s,r);return r}async setValue(t,e){B(this.state.values,t,e),this.state.touched[t]=!0,this.invalidateDependencyCache(t),this.state.touched[t]&&this.schema&&await this.validateField(t);let a=this.fieldDependencies.get(t);if(a)for(let r of a)await this.validateField(r);this.updateValidity()}invalidateDependencyCache(t){let e=this.fieldDependencies.get(t);if(e)for(let s of e){this.dependencyCache.delete(s);let i=this.addArrayIndexToPath(t,s);i&&this.dependencyCache.delete(i)}let a=t.replace(/\[\d+\]/g,"");if(a!==t){if(e=this.fieldDependencies.get(a),e)for(let i of e){this.dependencyCache.delete(i);let l=t.match(/\[(\d+)\]/);if(l){let n=i.includes("[")?i:`${i.split(".").slice(0,-1).join(".")}[${l[1]}].${i.split(".").pop()}`;this.dependencyCache.delete(n)}}let s=a.split(".").pop();if(s&&s!==a&&(e=this.fieldDependencies.get(s),e))for(let i of e){this.dependencyCache.delete(i);let l=t.match(/\[(\d+)\]/);if(l){let d=`${t.split(".")[0].replace(/\[\d+\]/,"")}[${l[1]}].${i}`;this.dependencyCache.delete(d)}}}let r=t.split(".");for(let s=1;s<r.length;s++){if(r[s].includes("["))continue;let i=r.slice(s).join(".");if(e=this.fieldDependencies.get(i),e)for(let l of e)this.dependencyCache.delete(l),this.dependencyCache.delete(`${r[0]}.${i}`)}this.dependencyCache.delete(t)}addArrayIndexToPath(t,e){let a=t.match(/\[(\d+)\]/);if(!a)return null;let r=a[1],s=t.split(".")[0];if(e.startsWith(s)){let i=e.split(".");if(i.length>1)return`${i[0]}[${r}].${i.slice(1).join(".")}`}return null}setValueWithoutValidation(t,e){B(this.state.values,t,e),this.invalidateDependencyCache(t)}async validateField(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],r=this.extractAllFields(e).find(n=>n.name===t);if(!r)return;if(!this.getFieldVisibility(t)){delete this.state.errors[t];return}let s=this.getValue(t),i=this.getActiveValidations(r),l=await this.validator.validateFieldWithValidations(r,s,i);l.length>0?this.state.errors[t]=l:delete this.state.errors[t]}getActiveValidations(t){let e=[...t.validations||[]],a=["text","email","password","textarea"],r=t.skipInjectionValidation??t.props?.skipInjectionValidation;a.includes(t.type)&&!r&&!e.some(l=>l.type==="noInjection")&&(e=[{type:"noInjection"},...e]);let s=this.getFieldRequired(t.name),i=e.some(l=>l.type==="required");if(s&&!i?e=[{type:"required"},...e]:!s&&i&&(e=e.filter(l=>l.type!=="required")),t.conditionalValidations)for(let l of t.conditionalValidations)this.conditionEngine.evaluateConditions(l.condition,this.state.values)&&(e=[...e,...l.validations]);return e}async validateForm(){if(!this.schema)return{};let t=this.schema.isWizard?this.schema.steps.flatMap(r=>r.fields):this.schema.fields||[],e=this.extractAllFields(t),a=await this.validator.validateForm(e,this.state.values);return this.state.errors=a,this.updateValidity(),a}updateValidity(){this.state.isValid=Object.keys(this.state.errors).length===0}setTouched(t){this.state.touched[t]=!0}getErrors(t){return this.state.errors[t]||[]}getAllErrors(){return{...this.state.errors}}reset(){this.state=this.createInitialState(),this.schema&&(this.initializeValues(),this.initializeWizard())}nextStep(){return this.wizardState&&this.wizardState.currentStep<this.wizardState.totalSteps-1?(this.wizardState.currentStep++,!0):!1}previousStep(){return this.wizardState&&this.wizardState.currentStep>0?(this.wizardState.currentStep--,!0):!1}goToStep(t){return this.wizardState&&t>=0&&t<this.wizardState.totalSteps?(this.wizardState.currentStep=t,!0):!1}completeStep(t){this.wizardState&&(this.wizardState.completedSteps.includes(t)||this.wizardState.completedSteps.push(t))}setSubmitting(t){this.state.isSubmitting=t}getCurrentStepFields(){return!this.schema||!this.schema.isWizard||!this.wizardState?this.schema?.fields||[]:this.schema.steps[this.wizardState.currentStep].fields}getFieldVisibility(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.visible;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(p=>p.fields):this.schema.fields||[],r=this.extractAllFieldsWithArrays(a),s=r.find(p=>p.fullPath===t||p.field.name===t);if(!s){let p=t.replace(/\[\d+\]/g,"");s=r.find(u=>u.field.name===p||u.fullPath===p)}if(!s){let p=t.split(".").pop();s=r.find(u=>u.field.name===p)}if(!s||!s.field.dependencies)return!s?.field.hidden;let{field:i,containerType:l,containerPath:n}=s,d=s.field.dependencies,c={...this.state.values};if(l==="array"&&n){let p,u=g=>{if(g)return Array.isArray(g)?g[0]?.field:g.field};if(p=u(d.show)||u(d.hide)||u(d.enable)||u(d.disable)||u(d.required)||u(d.optional),p&&p){let g=t.match(/\[(\d+)\]/),f=g?parseInt(g[1],10):null,y=null;if(f!==null){let v=I(this.state.values,n);if(Array.isArray(v)&&v[f]&&(y=v[f][p]),y==null){let b=`${n}[${f}]`,w=this.state.values[b];w&&typeof w=="object"&&(y=w[p])}}else{let v=I(this.state.values,n);if(Array.isArray(v)){for(let b of v)if(b&&b[p]!==void 0){y=b[p];break}}}if(y!=null){let v={...this.state.values};v[p]=y;let b=this.conditionEngine.evaluateDependencies(d,v);return this.dependencyCache.set(t,b),b.visible&&!i.hidden}}let h={visible:!0,enabled:!0,required:!1};return this.dependencyCache.set(t,h),h.visible&&!i.hidden}else if(n){let p=I(this.state.values,n);if(p&&typeof p=="object"){let u=(g,f="")=>{let y={},v=Object.entries(g);for(let[b,w]of v){let S=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null&&Object.assign(y,u(w,S))}for(let[b,w]of v){let S=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null||S in y||(y[S]=w)}return y},h=u(p);c={...this.state.values,...h}}}let m=this.conditionEngine.evaluateDependencies(d,c);return this.dependencyCache.set(t,m),m.visible&&!i.hidden}getFieldEnabled(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.enabled;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(l=>l.fields):this.schema.fields||[],s=this.extractAllFields(a).find(l=>l.name===t);if(!s)return!0;if(s.disabled)return!1;if(!s.dependencies)return!0;let i=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,i),i.enabled}getFieldRequired(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.required;if(!this.schema)return!1;let a=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],s=this.extractAllFields(a).find(n=>n.name===t);if(!s)return!1;let i=s.validations?.some(n=>n.type==="required")||!1;if(!s.dependencies)return i;let l=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,l),l.required||i}getDependentFields(t){return Array.from(this.fieldDependencies.get(t)||[])}};var x=class{constructor(t,e,a,r,s){this.field=t,this.value=e,this.error=a,this.onChange=r,this.onBlur=s}createInputWithSlots(t){let e=this.field.leadingIcon,a=this.field.trailingIcon;if(!e&&!a)return t;let r=document.createElement("div");if(r.className="easy-form-input-wrapper",e&&this.isSlotContentValid(e)){let i=this.renderSlotContent(e);i.className="easy-form-input-slot easy-form-input-slot-leading",r.appendChild(i)}let s=document.createElement("div");if(s.className="easy-form-input-core",s.appendChild(t),r.appendChild(s),a&&this.isSlotContentValid(a)){let i=this.renderSlotContent(a);i.className="easy-form-input-slot easy-form-input-slot-trailing",r.appendChild(i)}return r}isSlotContentValid(t){return t.type?t.type==="image"?!!t.src:t.type==="html"?!!t.html:!1:!1}renderSlotContent(t){let e=document.createElement("span");if(e.className="easy-form-input-slot-content",t.type==="image"&&t.src){let a=document.createElement("img");a.src=t.src,a.alt=t.alt??"",a.setAttribute("aria-hidden","true"),e.appendChild(a)}else t.type==="html"&&t.html&&(e.innerHTML=t.html);return e}createFieldContainer(t){let e=document.createElement("div"),r=Array.from(t.classList).filter(d=>d.startsWith("easy-form-")&&d!=="easy-form-field"&&(d.includes("-container")||d.includes("-wrapper"))),s=this.field.labelPosition??"up",i=this.createInputWithSlots(t);if(r.length>0?e.className=`easy-form-field easy-form-label-${s} ${r.join(" ")}`:e.className=`easy-form-field easy-form-label-${s}`,s==="none"&&this.field.label){let d=i.querySelector("input, textarea, select")||i;d instanceof HTMLElement&&d.setAttribute("aria-label",this.field.label)}let n=(()=>{if(!this.field.label||s==="none")return null;let d=document.createElement("label");if(d.className="easy-form-label",d.setAttribute("for",this.getFieldId()),d.textContent=this.field.label,this.field.validations?.some(c=>c.type==="required")){let c=document.createElement("span");c.className="easy-form-required",c.textContent=" *",d.appendChild(c)}return d})();if(s==="up")n&&e.appendChild(n),e.appendChild(i);else if(s==="down")e.appendChild(i),n&&e.appendChild(n);else if(s==="left"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",n&&d.appendChild(n),d.appendChild(i),e.appendChild(d)}else if(s==="right"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",d.appendChild(i),n&&d.appendChild(n),e.appendChild(d)}else e.appendChild(i);if(this.field.description){let d=document.createElement("p");d.className="easy-form-description",d.textContent=this.field.description,e.appendChild(d)}if(this.error){let d=document.createElement("p");d.className="easy-form-error",d.textContent=this.error,e.appendChild(d)}return e}getFieldId(){return`easy-form-${this.field.name}`}applyCommonProps(t){if(t.id=this.getFieldId(),t.setAttribute("name",this.field.name),this.field.disabled&&(t.setAttribute("disabled","true"),t.classList.add("easy-form-input-disabled")),this.field.hidden&&(t.style.display="none",t.classList.add("easy-form-field-hidden")),this.error&&t.classList.add("easy-form-input-error"),this.field.props)for(let[e,a]of Object.entries(this.field.props))(e.startsWith("data-")||e.startsWith("aria-"))&&t.setAttribute(e,String(a))}};function vt(o){let t=[];for(let e=0;e<o.length;e++){let a=o[e];switch(a){case"9":t.push({type:"digit",char:"9",editable:!0});break;case"a":case"A":t.push({type:"letter",char:a,editable:!0});break;case"*":t.push({type:"any",char:"*",editable:!0});break;default:t.push({type:"literal",char:a,editable:!1});break}}return t}function G(o,t){let e="",a=0;for(let r of t){if(!r.editable){e+=r.char;continue}if(a>=o.length)break;let s=o[a];if(!(r.type==="digit"&&!/\d/.test(s))){{if(r.type==="letter"&&!/[a-zA-Z]/.test(s))continue;if(r.type!=="any"){if(r.type!=="any"&&r.type!=="digit"&&r.type!=="letter")continue}}e+=s,a++}}return e}function He(o,t){if(!o)return"";let e="",a=0;for(let r=0;r<o.length&&a<t.length;r++){let s=o[r],i=t[a];if(i.editable)i.type==="digit"&&/\d/.test(s)||i.type==="letter"&&/[a-zA-Z]/.test(s)||i.type==="any"?(e+=s,a++):(a++,r--);else if(s===i.char)a++;else if(a<t.length-1){let l=t[a+1];l&&l.editable&&(l.type==="digit"&&/\d/.test(s)||l.type==="letter"&&/[a-zA-Z]/.test(s)||l.type==="any")?(e+=s,a+=2):a++}else break}return e}function ae(o,t,e="forward"){if(e==="forward"){for(let a=o+1;a<t.length;a++)if(t[a].editable)return a;return t.length}else{for(let a=o-1;a>=0;a--)if(t[a].editable)return a;return 0}}function xt(o,t="_"){return o.map(e=>e.editable?t:e.char).join("")}function kt(o,t,e,a){let r=0;for(let i=0;i<Math.min(e,o.length);i++){let l=i;l<a.length&&a[l].editable&&r++}let s=0;for(let i=0;i<t.length&&i<a.length;i++)if(a[i].editable&&(s++,s>r))return i+1;return ae(Math.min(e,t.length-1),a,"forward")}var N=class{constructor(){this.tokenCache=new Map}getCustomMask(t){return t.custom?t.custom:t.type?Ve(t.type):null}getTokens(t){let e=this.getCustomMask(t);if(!e)return null;let a=e.pattern;if(this.tokenCache.has(a))return this.tokenCache.get(a);let r=vt(e.pattern);return this.tokenCache.set(a,r),r}applyMask(t,e){let a=this.getTokens(e);if(!a)return t;let r=this.getCustomMask(e),s=a.filter(d=>d.editable),i=new Set(s.map(d=>d.type)),l="";for(let d of t)(i.has("any")||i.has("digit")&&/\d/.test(d)||i.has("letter")&&/[a-zA-Z]/.test(d))&&(l+=d);let n=G(l,a);return r.transform&&(n=r.transform(n),n=G(n,a)),n}removeMask(t,e){let a=this.getTokens(e);return a?He(t,a):t}getMaskPlaceholder(t){let e=this.getTokens(t);if(!e)return"";let a=this.getCustomMask(t);return xt(e,a.placeholder||"_")}canInsertChar(t,e,a){let r=this.getTokens(a);if(!r||e>=r.length)return!1;let s=r[e];if(!s.editable)return!1;switch(s.type){case"digit":return/\d/.test(t);case"letter":return/[a-zA-Z]/.test(t);case"any":return!0;default:return!1}}processInput(t,e,a,r){let s=this.getTokens(a);if(!s)return{value:t,cursorPosition:t.length};let i=He(t,s),l=G(i,s),n=this.getCustomMask(a);n.transform&&(l=n.transform(l),l=G(l,s));let d=kt(e,l,r,s);return{value:l,cursorPosition:Math.min(d,l.length)}}processKeyInput(t,e,a,r,s=!1){let i=this.getTokens(r);if(!i)return{value:e,cursorPosition:a};if(s){if(a===0)return{value:e,cursorPosition:0};let l=ae(a-1,i,"backward"),n=e.substring(0,l),d=e.substring(a),c=n+d,m=this.removeMask(c,r),p=this.applyMask(m,r),u=Math.max(0,l-1),h=ae(u,i,"forward");return{value:p,cursorPosition:h}}if(t.length===1&&this.canInsertChar(t,a,r)){let l=e.substring(0,a),n=e.substring(a),d=l+t+n;return this.processInput(d,e,r,a)}return{value:e,cursorPosition:a}}};var se=class extends x{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new N)}render(){let e=document.createElement("input");e.type=this.field.type==="email"?"email":this.field.type==="password"?"password":"text";let a=this.value??"";if(this.maskEngine&&this.field.mask&&(a&&(a=this.maskEngine.applyMask(String(a),this.field.mask)),this.previousValue=a),e.value=a,this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,l=s.value,n=this.maskEngine.processInput(l,this.previousValue,this.field.mask,i);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=this.field.mask.keepFormat?n.value:this.maskEngine.removeMask(n.value,this.field.mask);this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let l=r.key==="Backspace",n=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,l);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=this.field.mask.keepFormat?n.value:this.maskEngine.removeMask(n.value,this.field.mask);this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,l=i.selectionStart||0,n=i.value.substring(0,l),d=i.value.substring(l),c=n+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,l);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=this.field.mask.keepFormat?m.value:this.maskEngine.removeMask(m.value,this.field.mask);this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target;this.onChange(s.value)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var ie=class extends x{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new N)}render(){let e=document.createElement("input");if(this.maskEngine&&this.field.mask){e.type="text";let r=this.value??"";r!==null&&r!==""&&(this.field.mask.type==="currency"?r=this.maskEngine.applyMask(String(r),this.field.mask):this.field.mask.type==="percentage"&&(r=this.maskEngine.applyMask(String(r),this.field.mask))),this.previousValue=r,e.value=r}else e.type="number",e.value=this.value??"";let a=this.field;if(!this.maskEngine&&e.type==="number"&&(a.min!==void 0&&(e.min=String(a.min)),a.max!==void 0&&(e.max=String(a.max)),a.step!==void 0&&(e.step=String(a.step))),this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,l=s.value,n=this.maskEngine.processInput(l,this.previousValue,this.field.mask,i);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let l=r.key==="Backspace",n=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,l);s.value=n.value,this.previousValue=n.value,setTimeout(()=>{s.setSelectionRange(n.cursorPosition,n.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(n.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,l=i.selectionStart||0,n=i.value.substring(0,l),d=i.value.substring(l),c=n+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,l);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=null;if(this.field.mask.type==="currency"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u):null}this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target,i=s.value===""?null:Number(s.value);this.onChange(i)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var oe=class extends x{render(){let t=document.createElement("textarea");t.value=this.value??"",t.placeholder=this.field.placeholder||"";let e=this.field;return e.rows&&(t.rows=e.rows),e.cols&&(t.cols=e.cols),this.applyCommonProps(t),t.addEventListener("input",a=>{let r=a.target;this.onChange(r.value)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ne=class extends x{render(){let t=document.createElement("select"),e=this.field;if(e.multiple&&(t.multiple=!0),!e.multiple){let r=document.createElement("option");r.value="",r.textContent=e.placeholder||"Selecciona una opci\xF3n",r.setAttribute("data-placeholder",""),r.disabled=!0,t.appendChild(r)}for(let r of e.options){let s=document.createElement("option");typeof r=="string"?(s.value=r,s.textContent=r):(s.value=String(r.value),s.textContent=r.label),t.appendChild(s)}if(e.multiple&&Array.isArray(this.value))for(let r of t.options)r.selected=this.value.includes(r.value);else t.value=this.value??"";this.applyCommonProps(t);let a=()=>{!t.value?t.classList.add("easy-form-select-placeholder"):t.classList.remove("easy-form-select-placeholder")};return a(),t.addEventListener("change",r=>{let s=r.target;if(a(),e.multiple){let i=Array.from(s.selectedOptions).map(l=>l.value);this.onChange(i)}else this.onChange(s.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var le=class extends x{render(){let t=document.createElement("input");t.type="checkbox",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-checkbox",a.setAttribute("for",this.getFieldId()),a.appendChild(t),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var de=class extends x{render(){let t=document.createElement("div");if(t.className="easy-form-field",this.field.label){let r=document.createElement("label");if(r.className="easy-form-label",r.textContent=this.field.label,this.field.validations?.some(s=>s.type==="required")){let s=document.createElement("span");s.className="easy-form-required",s.textContent=" *",r.appendChild(s)}t.appendChild(r)}let e=document.createElement("div");e.className="easy-form-radio-group";let a=this.field;for(let r of a.options){let s=typeof r=="string"?r:r.value,i=typeof r=="string"?r:r.label,l=document.createElement("div");l.className="easy-form-radio-option";let n=document.createElement("input");n.type="radio",n.name=this.field.name,n.id=`${this.getFieldId()}-${s}`,n.value=String(s),n.checked=String(this.value)===String(s),this.field.disabled&&(n.disabled=!0);let d=document.createElement("label");d.setAttribute("for",n.id),d.textContent=i,d.className="easy-form-radio-label",n.addEventListener("change",()=>{this.onChange(s)}),n.addEventListener("blur",()=>{this.onBlur()}),l.appendChild(n),l.appendChild(d),e.appendChild(l)}if(t.appendChild(e),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,t.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,t.appendChild(r)}return t}};var ce=class extends x{render(){let t=document.createElement("input");t.type="checkbox",t.className="easy-form-switch",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-switch",a.setAttribute("for",this.getFieldId()),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(a.appendChild(t),e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var pe=class extends x{render(){let t=document.createElement("input");t.type="date";let e=this.field;if(e.min&&(t.min=e.min),e.max&&(t.max=e.max),this.value){let a=this.value instanceof Date?this.value.toISOString().split("T")[0]:String(this.value);t.value=a}return this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;this.onChange(r.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var me=class extends x{render(){let t=document.createElement("input");t.type="file";let e=this.field;return e.accept&&(t.accept=e.accept),e.multiple&&(t.multiple=!0),this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;r.files&&(e.multiple?this.onChange(Array.from(r.files)):this.onChange(r.files[0]||null))}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ue=class extends x{render(){let t=document.createElement("div");t.className="easy-form-quantity-container";let e=this.field,a=e.min??0,r=e.max??void 0,s=e.step??1,i=this.value??a,l=document.createElement("div");l.className="easy-form-quantity-wrapper";let n=document.createElement("button");n.type="button",n.className="easy-form-quantity-btn easy-form-quantity-decrement",n.textContent="\u2212",n.setAttribute("aria-label","Decrementar"),i<=a&&(n.disabled=!0,n.classList.add("disabled"));let d=document.createElement("input");d.type="number",d.value=String(i),d.min=String(a),r!==void 0&&(d.max=String(r)),d.step=String(s),d.className="easy-form-quantity-input",this.applyCommonProps(d);let c=document.createElement("button");c.type="button",c.className="easy-form-quantity-btn easy-form-quantity-increment",c.textContent="+",c.setAttribute("aria-label","Incrementar"),r!==void 0&&i>=r&&(c.disabled=!0,c.classList.add("disabled")),n.addEventListener("click",()=>{let p=Math.max(a,Number(d.value)-s);d.value=String(p),this.onChange(p),m()}),c.addEventListener("click",()=>{let p=r!==void 0?Math.min(r,Number(d.value)+s):Number(d.value)+s;d.value=String(p),this.onChange(p),m()}),d.addEventListener("input",p=>{let u=p.target,h=Number(u.value);isNaN(h)&&(h=a),h<a&&(h=a),r!==void 0&&h>r&&(h=r),u.value=String(h),this.onChange(h),m()}),d.addEventListener("blur",()=>{this.onBlur()});let m=()=>{let p=Number(d.value);n.disabled=p<=a,n.classList.toggle("disabled",p<=a),r!==void 0?(c.disabled=p>=r,c.classList.toggle("disabled",p>=r)):(c.disabled=!1,c.classList.remove("disabled"))};return l.appendChild(n),l.appendChild(d),l.appendChild(c),t.appendChild(l),this.createFieldContainer(t)}};var fe=class extends x{constructor(){super(...arguments);this.openAccordion=null}render(){let e=document.createElement("div");e.className="easy-form-accordion-select-container";let a=this.field,r=this.value??null;return a.options.forEach((s,i)=>{let l=typeof s=="string"?s:s.value,n=typeof s=="string"?s:s.label,d=typeof s=="object"&&"description"in s&&s.description?s.description:void 0,c=document.createElement("div");c.className="easy-form-accordion-item",c.setAttribute("data-value",String(l)),(r===l||Array.isArray(r)&&r.includes(l))&&(c.classList.add("selected"),a.multiple||(this.openAccordion=String(l)));let m=document.createElement("div");m.className="easy-form-accordion-header",m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-expanded","false");let p=document.createElement("div");p.className="easy-form-accordion-header-content";let u=document.createElement("div");u.className="easy-form-accordion-indicator",a.multiple?(u.classList.add("checkbox"),Array.isArray(r)&&r.includes(l)&&u.classList.add("checked")):(u.classList.add("radio"),r===l&&u.classList.add("checked"));let h=document.createElement("span");h.className="easy-form-accordion-label",h.textContent=n;let g=document.createElement("span");g.className="easy-form-accordion-arrow",g.textContent="\u25BC",p.appendChild(u),p.appendChild(h),m.appendChild(p),m.appendChild(g);let f=document.createElement("div");if(f.className="easy-form-accordion-content",d){let b=document.createElement("p");b.className="easy-form-accordion-description",b.textContent=d,f.appendChild(b)}if(typeof s=="object"&&"content"in s&&s.content){let b=document.createElement("div");b.className="easy-form-accordion-custom-content",typeof s.content=="string"?b.innerHTML=s.content:s.content instanceof HTMLElement&&b.appendChild(s.content),f.appendChild(b)}c.appendChild(m),c.appendChild(f);let y=()=>{let b=c.classList.contains("open");a.multiple||e.querySelectorAll(".easy-form-accordion-item").forEach(w=>{if(w!==c){w.classList.remove("open");let S=w.querySelector(".easy-form-accordion-header"),k=w.querySelector(".easy-form-accordion-content"),F=w.querySelector(".easy-form-accordion-arrow");S&&S.setAttribute("aria-expanded","false"),k&&(k.style.maxHeight=null),F&&(F.style.transform="rotate(0deg)")}}),b?(c.classList.remove("open"),m.setAttribute("aria-expanded","false"),f.style.maxHeight=null,g.style.transform="rotate(0deg)",this.openAccordion=null):(c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)",this.openAccordion=String(l))},v=()=>{if(a.multiple){let b=Array.isArray(r)?[...r]:[],w=b.indexOf(l);w>-1?(b.splice(w,1),c.classList.remove("selected"),u.classList.remove("checked")):(b.push(l),c.classList.add("selected"),u.classList.add("checked")),this.onChange(b.length>0?b:null)}else e.querySelectorAll(".easy-form-accordion-item").forEach(b=>{b.classList.remove("selected");let w=b.querySelector(".easy-form-accordion-indicator");w&&w.classList.remove("checked")}),c.classList.add("selected"),u.classList.add("checked"),this.onChange(l)};m.addEventListener("click",b=>{b.stopPropagation(),v(),y()}),m.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),v(),y())}),(r===l||Array.isArray(r)&&r.includes(l))&&(!a.multiple||a.autoExpand)&&setTimeout(()=>{c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)"},0),e.appendChild(c)}),this.createFieldContainer(e)}};var he=class extends x{render(){let t=document.createElement("div");t.className="easy-form-image-grid-container";let e=this.field,a=this.value??null,r=e.columns??3,s=e.imageSize??"medium";return t.style.gridTemplateColumns=`repeat(${r}, 1fr)`,t.style.gap=e.gap??"1rem",e.options.forEach(i=>{let l=typeof i=="string"?i:i.value,n=typeof i=="string"?i:i.label,d=typeof i=="object"&&"image"in i&&i.image?i.image:void 0,c=typeof i=="object"&&"description"in i&&i.description?i.description:void 0,m=document.createElement("div");m.className=`easy-form-image-grid-item easy-form-image-grid-${s}`,m.setAttribute("data-value",String(l)),m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-label",n),(a===l||Array.isArray(a)&&a.includes(l))&&m.classList.add("selected");let p=document.createElement("div");if(p.className="easy-form-image-grid-image-container",d){let f=document.createElement("img");f.src=d,f.alt=n,f.className="easy-form-image-grid-image",p.appendChild(f)}else{let f=document.createElement("div");f.className="easy-form-image-grid-placeholder",f.textContent=n.charAt(0).toUpperCase(),p.appendChild(f)}let u=document.createElement("div");u.className="easy-form-image-grid-indicator",e.multiple?(u.classList.add("checkbox"),Array.isArray(a)&&a.includes(l)&&(u.classList.add("checked"),u.innerHTML="\u2713")):(u.classList.add("radio"),a===l&&(u.classList.add("checked"),u.innerHTML="\u25CF")),p.appendChild(u);let h=document.createElement("div");if(h.className="easy-form-image-grid-label",h.textContent=n,c){let f=document.createElement("div");f.className="easy-form-image-grid-description",f.textContent=c,m.appendChild(f)}m.appendChild(p),m.appendChild(h);let g=()=>{if(e.multiple){let f=Array.isArray(a)?[...a]:[],y=f.indexOf(l);y>-1?(f.splice(y,1),m.classList.remove("selected"),u.classList.remove("checked"),u.innerHTML=""):(f.push(l),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u2713"),this.onChange(f.length>0?f:null)}else t.querySelectorAll(".easy-form-image-grid-item").forEach(f=>{f.classList.remove("selected");let y=f.querySelector(".easy-form-image-grid-indicator");y&&(y.classList.remove("checked"),y.innerHTML="")}),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u25CF",this.onChange(l)};m.addEventListener("click",g),m.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),g())}),m.addEventListener("blur",()=>{this.onBlur()}),t.appendChild(m)}),this.createFieldContainer(t)}};var ge=class extends x{constructor(){super(...arguments);this.inputs=[]}render(){let e=document.createElement("div");e.className="easy-form-otp-container";let r=this.field.length??6,s=this.value??"",i=String(s).padStart(r,"").slice(0,r);for(let l=0;l<r;l++){let n=document.createElement("input");n.type="text",n.inputMode="numeric",n.maxLength=1,n.className="easy-form-otp-input",n.setAttribute("aria-label",`C\xF3digo d\xEDgito ${l+1}`),i[l]&&(n.value=i[l]),this.applyCommonProps(n),n.id=`${this.getFieldId()}-${l}`;let d=l;n.addEventListener("input",c=>{let m=c.target,p=m.value.replace(/[^0-9]/g,"");m.value=p,p&&d<r-1&&this.inputs[d+1].focus(),this.updateOTPValue()}),n.addEventListener("keydown",c=>{let m=c.target;c.key==="Backspace"&&!m.value&&d>0&&(this.inputs[d-1].focus(),this.inputs[d-1].value="",this.updateOTPValue()),c.key==="ArrowLeft"&&d>0&&(c.preventDefault(),this.inputs[d-1].focus()),c.key==="ArrowRight"&&d<r-1&&(c.preventDefault(),this.inputs[d+1].focus())}),n.addEventListener("paste",c=>{c.preventDefault();let p=(c.clipboardData||window.clipboardData).getData("text").replace(/[^0-9]/g,"").slice(0,r);for(let h=0;h<p.length&&d+h<r;h++)this.inputs[d+h].value=p[h];let u=Math.min(d+p.length,r-1);this.inputs[u].focus(),this.updateOTPValue()}),n.addEventListener("focus",c=>{c.target.select()}),n.addEventListener("blur",()=>{this.onBlur()}),this.inputs.push(n),e.appendChild(n)}return this.createFieldContainer(e)}updateOTPValue(){let e=this.inputs.map(s=>s.value).join(""),a=this.field,r=e.length===this.inputs.length?e:null;a.numeric&&r?this.onChange(Number(r)):this.onChange(r)}};var Qt=6;function be(o){return o?'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'}var ye=class extends x{constructor(){super(...arguments);this.inputs=[];this.visible=!1}get passwordField(){return this.field}render(){let e=this.passwordField,a=!!e.characterSeparated,r=a?typeof e.characterSeparated=="number"?e.characterSeparated:Qt:0;return a?this.createFieldContainer(this.renderSeparated(r)):this.createFieldContainer(this.renderSingle())}renderSingle(){let a=!!this.passwordField.showToggle,r=document.createElement("input");if(r.type="password",r.value=this.value??"",r.id=this.getFieldId(),this.applyCommonProps(r),this.field.placeholder&&(r.placeholder=this.field.placeholder),r.addEventListener("input",l=>{this.onChange(l.target.value)}),r.addEventListener("blur",()=>this.onBlur()),!a)return r;let s=document.createElement("div");s.className="easy-form-password-inner",r.classList.add("easy-form-password-input"),s.appendChild(r);let i=document.createElement("button");return i.type="button",i.className="easy-form-password-toggle",i.setAttribute("aria-label","Mostrar contrase\xF1a"),i.innerHTML=be(!1),i.addEventListener("click",()=>{this.visible=!this.visible,r.type=this.visible?"text":"password",i.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),i.innerHTML=be(this.visible)}),s.appendChild(i),s}renderSeparated(e){let r=!!this.passwordField.showToggle,s=this.value??"",i=String(s).slice(0,e),l=document.createElement("div");l.className="easy-form-password-separated";for(let n=0;n<e;n++){let d=document.createElement("input");d.type="password",d.maxLength=1,d.className="easy-form-password-separated-input",d.setAttribute("aria-label",`Car\xE1cter ${n+1} de ${e}`),i[n]&&(d.value=i[n]),this.applyCommonProps(d),d.id=n===0?this.getFieldId():`${this.getFieldId()}-${n}`,n>0&&d.removeAttribute("name");let c=n;d.addEventListener("input",m=>{m.target.value&&c<e-1&&this.inputs[c+1].focus(),this.updateSeparatedValue()}),d.addEventListener("keydown",m=>{m.key==="Backspace"&&!m.target.value&&c>0&&(this.inputs[c-1].focus(),this.inputs[c-1].value="",this.updateSeparatedValue()),m.key==="ArrowLeft"&&c>0&&(m.preventDefault(),this.inputs[c-1].focus()),m.key==="ArrowRight"&&c<e-1&&(m.preventDefault(),this.inputs[c+1].focus())}),d.addEventListener("paste",m=>{m.preventDefault();let u=((m.clipboardData||window.clipboardData)?.getData("text")||"").slice(0,e-c).split("");for(let g=0;g<u.length&&c+g<e;g++)this.inputs[c+g].value=u[g];let h=Math.min(c+u.length,e-1);this.inputs[h].focus(),this.updateSeparatedValue()}),d.addEventListener("focus",m=>m.target.select()),d.addEventListener("blur",()=>this.onBlur()),this.inputs.push(d),l.appendChild(d)}if(r){let n=document.createElement("div");n.className="easy-form-password-separated-toggle";let d=document.createElement("button");d.type="button",d.className="easy-form-password-toggle",d.setAttribute("aria-label","Mostrar contrase\xF1a"),d.innerHTML=be(!1),d.addEventListener("click",()=>{this.visible=!this.visible;let c=this.visible?"text":"password";this.inputs.forEach(m=>{m.type=c}),d.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),d.innerHTML=be(this.visible)}),n.appendChild(d),l.appendChild(n)}return l}updateSeparatedValue(){let e=this.inputs.map(a=>a.value).join("");this.onChange(e||null)}};var ve=class extends x{render(){let t=this.field,e=t.accept??"",a=t.multiple??!1,r=document.createElement("div");r.className="easy-form-file-drop",r.setAttribute("tabindex","0");let s=document.createElement("input");s.type="file",s.className="easy-form-file-drop-input",s.style.display="none",e&&(s.accept=e),a&&(s.multiple=!0);let i=document.createElement("span");i.className="easy-form-file-drop-label",i.textContent="Arrastra archivos aqu\xED o haz clic para seleccionar",r.appendChild(i),r.appendChild(s);let l=document.createElement("div");l.className="easy-form-file-drop-list";let n=c=>{let m=c?Array.isArray(c)?c.map(p=>p.name):[c.name]:[];if(l.innerHTML="",m.length===0){l.style.display="none";return}l.style.display="block",m.forEach(p=>{let u=document.createElement("div");u.className="easy-form-file-drop-item",u.textContent=p,l.appendChild(u)})};n(this.value);let d=c=>{if(!c||c.length===0)return;let m=a?Array.from(c):c[0];this.onChange(m),this.onBlur(),n(m)};return r.addEventListener("click",()=>{s.click()}),s.addEventListener("change",c=>{let m=c.target;d(m.files),m.value=""}),r.addEventListener("dragover",c=>{c.preventDefault(),c.stopPropagation(),r.classList.add("easy-form-file-drop-over")}),r.addEventListener("dragleave",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over")}),r.addEventListener("drop",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over"),d(c.dataTransfer?.files??null)}),r.appendChild(l),this.createFieldContainer(r)}};var Jt="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",xe=class extends x{constructor(){super(...arguments);this.mapInstance=null;this.markerInstance=null}render(){let e=this.field,a=e.center??{lat:0,lng:0},r=e.zoom??13,s=this.value,i=typeof s=="object"&&s?.lat!=null?s.lat:a.lat,l=typeof s=="object"&&s?.lng!=null?s.lng:a.lng,n=document.createElement("div");n.className="easy-form-map";let d=document.createElement("div");d.className="easy-form-map-inputs";let c=document.createElement("input");c.type="number",c.step="any",c.placeholder="Latitud",c.value=String(i),c.className="easy-form-map-lat";let m=document.createElement("input");m.type="number",m.step="any",m.placeholder="Longitud",m.value=String(l),m.className="easy-form-map-lng";let p=()=>{let v=parseFloat(c.value),b=parseFloat(m.value);!isNaN(v)&&!isNaN(b)&&(this.onChange({lat:v,lng:b}),this.syncMarkerPosition(v,b)),this.onBlur()};c.addEventListener("change",p),m.addEventListener("change",p),d.appendChild(c),d.appendChild(m),n.appendChild(d);let u=document.createElement("div");u.className="easy-form-map-container",n.appendChild(u);let h="easy-form-leaflet-css",g=!1,f=document.createElement("link");return f.id=h,f.rel="stylesheet",f.href=Jt,f.onload=()=>{g=!0},n.insertBefore(f,n.firstChild),(async()=>{if(typeof window>"u")return;u.style.height="300px",u.style.width="100%",u.style.position="relative",u.style.overflow="hidden",u.style.display="block",await new Promise(k=>{let F=()=>{g&&u.offsetWidth>0&&u.offsetHeight>0?k(void 0):requestAnimationFrame(F)};F()}),await new Promise(k=>setTimeout(k,50));let v;try{v=await import("leaflet")}catch{u.innerHTML=`
|
|
2536
2655
|
<div style="padding:2rem;text-align:center;color:#666;font-size:0.875rem;background:#f9f9f9;border-radius:4px;">
|
|
2537
2656
|
<strong>Campo map requiere Leaflet</strong><br><br>
|
|
2538
2657
|
Instala e importa Leaflet para usar el mapa interactivo:<br>
|
|
@@ -2540,12 +2659,12 @@ Please report this to https://github.com/markedjs/marked.`,o){let a="<p>An error
|
|
|
2540
2659
|
En tu app: <code>import 'leaflet'</code> y <code>import 'leaflet/dist/leaflet.css'</code><br>
|
|
2541
2660
|
<a href="https://easyforms.dev/docs/tipos-campos#map" target="_blank" rel="noopener" style="color:var(--easy-form-primary,#007bff);">Ver documentaci\xF3n</a>
|
|
2542
2661
|
</div>
|
|
2543
|
-
`;return}delete x.Icon.Default.prototype._getIconUrl,x.Icon.Default.mergeOptions({iconRetinaUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png",iconUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png"}),this.mapInstance=x.map(u,{preferCanvas:!1,zoomControl:!0}).setView([i,l],r);let b=x.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(this.mapInstance);this.mapInstance.invalidateSize(),b.on("load",()=>{this.mapInstance&&this.mapInstance.invalidateSize()});let w=()=>{this.mapInstance&&this.mapInstance.invalidateSize()};setTimeout(w,100),setTimeout(w,300),setTimeout(w,500),new IntersectionObserver(k=>{k.forEach(F=>{F.isIntersecting&&this.mapInstance&&setTimeout(()=>{this.mapInstance?.invalidateSize()},100)})}).observe(u),this.markerInstance=x.marker([i,l],{draggable:!0}).addTo(this.mapInstance).on("dragend",()=>{let k=this.markerInstance.getLatLng();c.value=String(Number(k.lat.toFixed(6))),m.value=String(Number(k.lng.toFixed(6))),this.onChange({lat:k.lat,lng:k.lng}),this.onBlur()}),this.mapInstance.on("click",k=>{let{lat:F,lng:$}=k.latlng;this.markerInstance.setLatLng([F,$]),c.value=String(Number(F.toFixed(6))),m.value=String(Number($.toFixed(6))),this.onChange({lat:F,lng:$}),this.onBlur()})})(),this.createFieldContainer(n)}syncMarkerPosition(e,a){this.mapInstance&&this.markerInstance&&(this.markerInstance.setLatLng([e,a]),this.mapInstance.setView([e,a]),setTimeout(()=>{this.mapInstance?.invalidateSize()},50))}};var wt=o=>`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="${o?"currentColor":"none"}" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" role="img" aria-hidden="true"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>`,ke=class extends v{render(){let t=this.field,e=t.max??5,a=t.half??!1,r=this.value!=null?Number(this.value):0,s=document.createElement("div");s.className="easy-form-rating",s.setAttribute("role","slider"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuemax",String(e)),s.setAttribute("aria-valuenow",String(r)),s.setAttribute("aria-label",this.field.label||"Rating"),s.setAttribute("tabindex","0");let i=document.createElement("div");i.className="easy-form-rating-stars";for(let l=1;l<=e;l++){let n=document.createElement("button");n.type="button";let d=r>=l||a&&r>=l-.5;n.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",n.innerHTML=wt(d),n.setAttribute("aria-label",`${l} de ${e}`),n.addEventListener("click",c=>{c.preventDefault();let m=c.target.closest("button")?.getBoundingClientRect(),p=l;if(a&&m){let u=m.left+m.width/2;p=c.clientX<u?l-.5:l}this.onChange(p),this.onBlur(),this.rerenderStars(s,e,p,a),s.setAttribute("aria-valuenow",String(p))}),i.appendChild(n)}return s.appendChild(i),s.addEventListener("keydown",l=>{let n=Number(s.getAttribute("aria-valuenow"))||0,d=n;l.key==="ArrowRight"||l.key==="ArrowUp"?(l.preventDefault(),d=Math.min(e,a?n+.5:n+1),this.onChange(d)):(l.key==="ArrowLeft"||l.key==="ArrowDown")&&(l.preventDefault(),d=Math.max(0,a?n-.5:n-1),this.onChange(d)),d!==n&&(this.rerenderStars(s,e,d,a),s.setAttribute("aria-valuenow",String(d)))}),this.createFieldContainer(s)}rerenderStars(t,e,a,r){t.querySelectorAll(".easy-form-rating-star").forEach((i,l)=>{let n=l+1,d=a>=n||r&&a>=n-.5;i.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",i.innerHTML=wt(d)})}};var we=class extends v{render(){let t=this.field,e=t.min??0,a=t.max??100,r=t.step??1,s=t.showValue??!1,i=document.createElement("input");i.type="range",i.min=String(e),i.max=String(a),i.step=String(r),i.value=this.value!=null?String(this.value):String(e),i.setAttribute("aria-valuemin",String(e)),i.setAttribute("aria-valuemax",String(a)),i.setAttribute("aria-valuenow",i.value),this.applyCommonProps(i),i.addEventListener("input",n=>{let d=n.target,c=r>=1?parseInt(d.value,10):parseFloat(d.value);this.onChange(isNaN(c)?e:c),l&&(l.textContent=d.value),i.setAttribute("aria-valuenow",d.value)}),i.addEventListener("change",()=>{this.onBlur()});let l=null;if(s){l=document.createElement("span"),l.className="easy-form-slider-value",l.textContent=i.value;let n=document.createElement("div");return n.className="easy-form-slider-wrapper",n.appendChild(i),n.appendChild(l),this.createFieldContainer(n)}return this.createFieldContainer(i)}};var Xt=/^#?([0-9A-Fa-f]{6})$/;function Be(o){let t=o.match(Xt);return t?`#${t[1].toLowerCase()}`:/^[0-9A-Fa-f]{6}$/.test(o)?`#${o.toLowerCase()}`:"#000000"}var Se=class extends v{render(){let e=this.field.defaultValue??"#000000",a=this.value!=null&&typeof this.value=="string"?Be(this.value):e,r=document.createElement("div");r.className="easy-form-color-wrapper";let s=document.createElement("input");s.type="color",s.value=a,s.setAttribute("value",a),s.setAttribute("aria-label",this.field.label||"Color"),s.id=`${this.getFieldId()}-picker`,this.field.disabled&&s.setAttribute("disabled","true");let i=document.createElement("input");i.type="text",i.value=a,i.setAttribute("aria-label",`${this.field.label||"Color"} (hex)`),i.placeholder="#000000",i.className="easy-form-color-text",this.applyCommonProps(i);let l=()=>{let d=s.value||"#000000",c=Be(d);i.value=c,this.onChange(c)},n=()=>{let d=i.value.trim(),c=d.startsWith("#")?d:`#${d}`;if(/^#[0-9A-Fa-f]{6}$/.test(c)){let m=Be(c);s.value=m,this.onChange(m)}};return s.addEventListener("input",l),s.addEventListener("change",()=>{l(),this.onBlur()}),i.addEventListener("input",n),i.addEventListener("blur",()=>{n(),this.onBlur()}),r.appendChild(s),r.appendChild(i),this.createFieldContainer(r)}};var Me=class extends v{constructor(){super(...arguments);this.textareaEl=null;this.previewEl=null}render(){let e=this.field,a=e.preview??!0,r=e.toolbar??!0,s=e.height??"300px",i=document.createElement("div");if(i.className="easy-form-markdown",r){let d=this.createToolbar();i.appendChild(d)}let l=document.createElement("div");l.className="easy-form-markdown-editor-wrapper";let n=document.createElement("textarea");if(n.className="easy-form-markdown-textarea",n.value=this.value||"",n.placeholder=e.placeholder||"Escribe en Markdown...",n.style.height=s,this.textareaEl=n,n.addEventListener("input",()=>{this.onChange(n.value),this.updatePreview()}),n.addEventListener("blur",()=>{this.onBlur()}),l.appendChild(n),i.appendChild(l),a){let d=document.createElement("div");d.className="easy-form-markdown-preview",d.style.height=s,this.previewEl=d,this.value?this.renderPreview(this.value,d):d.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>',l.appendChild(d)}return this.checkAndShowDependenciesMessage(),this.createFieldContainer(i)}createToolbar(){let e=document.createElement("div");return e.className="easy-form-markdown-toolbar",[{icon:"<strong>B</strong>",title:"Negrita",prefix:"**",suffix:"**",placeholder:"texto en negrita"},{icon:"<em>I</em>",title:"Cursiva",prefix:"_",suffix:"_",placeholder:"texto en cursiva"},{icon:"H1",title:"Encabezado 1",prefix:"# ",suffix:"",placeholder:"t\xEDtulo"},{icon:"H2",title:"Encabezado 2",prefix:"## ",suffix:"",placeholder:"t\xEDtulo"},{icon:"\u{1F517}",title:"Enlace",prefix:"[",suffix:"](url)",placeholder:"texto del enlace"},{icon:"<code></></code>",title:"C\xF3digo",prefix:"`",suffix:"`",placeholder:"c\xF3digo"},{icon:"\u{1F4F7}",title:"Imagen",prefix:"",placeholder:"texto alternativo"},{icon:"\u2022",title:"Lista",prefix:"- ",suffix:"",placeholder:"elemento"},{icon:"1.",title:"Lista numerada",prefix:"1. ",suffix:"",placeholder:"elemento"},{icon:'"',title:"Cita",prefix:"> ",suffix:"",placeholder:"cita"}].forEach(r=>{let s=document.createElement("button");s.type="button",s.className="easy-form-markdown-toolbar-btn",s.title=r.title,s.innerHTML=r.icon,s.addEventListener("click",()=>this.insertMarkdown(r.prefix,r.suffix,r.placeholder)),e.appendChild(s)}),e}insertMarkdown(e,a,r){let s=this.textareaEl;if(!s)return;let i=s.selectionStart,l=s.selectionEnd,n=s.value,d=n.substring(i,l)||(r??""),c=n.substring(0,i)+e+d+a+n.substring(l);s.value=c;let m=i+e.length+d.length;s.setSelectionRange(m,m),s.focus(),this.onChange(c),this.updatePreview()}updatePreview(){if(!this.previewEl)return;let e=this.textareaEl?.value||"";if(!e){this.previewEl.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>';return}this.renderPreview(e,this.previewEl)}async renderPreview(e,a){a.innerHTML='<div class="easy-form-markdown-preview-loading">Cargando...</div>';try{let r=await Promise.resolve().then(()=>(Xe(),Je)),i=await(r.default||r).parse(e);a.innerHTML=i}catch{a.innerHTML=`
|
|
2662
|
+
`;return}delete v.Icon.Default.prototype._getIconUrl,v.Icon.Default.mergeOptions({iconRetinaUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png",iconUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png"}),this.mapInstance=v.map(u,{preferCanvas:!1,zoomControl:!0}).setView([i,l],r);let b=v.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(this.mapInstance);this.mapInstance.invalidateSize(),b.on("load",()=>{this.mapInstance&&this.mapInstance.invalidateSize()});let w=()=>{this.mapInstance&&this.mapInstance.invalidateSize()};setTimeout(w,100),setTimeout(w,300),setTimeout(w,500),new IntersectionObserver(k=>{k.forEach(F=>{F.isIntersecting&&this.mapInstance&&setTimeout(()=>{this.mapInstance?.invalidateSize()},100)})}).observe(u),this.markerInstance=v.marker([i,l],{draggable:!0}).addTo(this.mapInstance).on("dragend",()=>{let k=this.markerInstance.getLatLng();c.value=String(Number(k.lat.toFixed(6))),m.value=String(Number(k.lng.toFixed(6))),this.onChange({lat:k.lat,lng:k.lng}),this.onBlur()}),this.mapInstance.on("click",k=>{let{lat:F,lng:$}=k.latlng;this.markerInstance.setLatLng([F,$]),c.value=String(Number(F.toFixed(6))),m.value=String(Number($.toFixed(6))),this.onChange({lat:F,lng:$}),this.onBlur()})})(),this.createFieldContainer(n)}syncMarkerPosition(e,a){this.mapInstance&&this.markerInstance&&(this.markerInstance.setLatLng([e,a]),this.mapInstance.setView([e,a]),setTimeout(()=>{this.mapInstance?.invalidateSize()},50))}};var wt=o=>`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="${o?"currentColor":"none"}" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" role="img" aria-hidden="true"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>`,ke=class extends x{render(){let t=this.field,e=t.max??5,a=t.half??!1,r=this.value!=null?Number(this.value):0,s=document.createElement("div");s.className="easy-form-rating",s.setAttribute("role","slider"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuemax",String(e)),s.setAttribute("aria-valuenow",String(r)),s.setAttribute("aria-label",this.field.label||"Rating"),s.setAttribute("tabindex","0");let i=document.createElement("div");i.className="easy-form-rating-stars";for(let l=1;l<=e;l++){let n=document.createElement("button");n.type="button";let d=r>=l||a&&r>=l-.5;n.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",n.innerHTML=wt(d),n.setAttribute("aria-label",`${l} de ${e}`),n.addEventListener("click",c=>{c.preventDefault();let m=c.target.closest("button")?.getBoundingClientRect(),p=l;if(a&&m){let u=m.left+m.width/2;p=c.clientX<u?l-.5:l}this.onChange(p),this.onBlur(),this.rerenderStars(s,e,p,a),s.setAttribute("aria-valuenow",String(p))}),i.appendChild(n)}return s.appendChild(i),s.addEventListener("keydown",l=>{let n=Number(s.getAttribute("aria-valuenow"))||0,d=n;l.key==="ArrowRight"||l.key==="ArrowUp"?(l.preventDefault(),d=Math.min(e,a?n+.5:n+1),this.onChange(d)):(l.key==="ArrowLeft"||l.key==="ArrowDown")&&(l.preventDefault(),d=Math.max(0,a?n-.5:n-1),this.onChange(d)),d!==n&&(this.rerenderStars(s,e,d,a),s.setAttribute("aria-valuenow",String(d)))}),this.createFieldContainer(s)}rerenderStars(t,e,a,r){t.querySelectorAll(".easy-form-rating-star").forEach((i,l)=>{let n=l+1,d=a>=n||r&&a>=n-.5;i.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",i.innerHTML=wt(d)})}};var we=class extends x{render(){let t=this.field,e=t.min??0,a=t.max??100,r=t.step??1,s=t.showValue??!1,i=document.createElement("input");i.type="range",i.min=String(e),i.max=String(a),i.step=String(r),i.value=this.value!=null?String(this.value):String(e),i.setAttribute("aria-valuemin",String(e)),i.setAttribute("aria-valuemax",String(a)),i.setAttribute("aria-valuenow",i.value),this.applyCommonProps(i),i.addEventListener("input",n=>{let d=n.target,c=r>=1?parseInt(d.value,10):parseFloat(d.value);this.onChange(isNaN(c)?e:c),l&&(l.textContent=d.value),i.setAttribute("aria-valuenow",d.value)}),i.addEventListener("change",()=>{this.onBlur()});let l=null;if(s){l=document.createElement("span"),l.className="easy-form-slider-value",l.textContent=i.value;let n=document.createElement("div");return n.className="easy-form-slider-wrapper",n.appendChild(i),n.appendChild(l),this.createFieldContainer(n)}return this.createFieldContainer(i)}};var Xt=/^#?([0-9A-Fa-f]{6})$/;function Be(o){let t=o.match(Xt);return t?`#${t[1].toLowerCase()}`:/^[0-9A-Fa-f]{6}$/.test(o)?`#${o.toLowerCase()}`:"#000000"}var Se=class extends x{render(){let e=this.field.defaultValue??"#000000",a=this.value!=null&&typeof this.value=="string"?Be(this.value):e,r=document.createElement("div");r.className="easy-form-color-wrapper";let s=document.createElement("input");s.type="color",s.value=a,s.setAttribute("value",a),s.setAttribute("aria-label",this.field.label||"Color"),s.id=`${this.getFieldId()}-picker`,this.field.disabled&&s.setAttribute("disabled","true");let i=document.createElement("input");i.type="text",i.value=a,i.setAttribute("aria-label",`${this.field.label||"Color"} (hex)`),i.placeholder="#000000",i.className="easy-form-color-text",this.applyCommonProps(i);let l=()=>{let d=s.value||"#000000",c=Be(d);i.value=c,this.onChange(c)},n=()=>{let d=i.value.trim(),c=d.startsWith("#")?d:`#${d}`;if(/^#[0-9A-Fa-f]{6}$/.test(c)){let m=Be(c);s.value=m,this.onChange(m)}};return s.addEventListener("input",l),s.addEventListener("change",()=>{l(),this.onBlur()}),i.addEventListener("input",n),i.addEventListener("blur",()=>{n(),this.onBlur()}),r.appendChild(s),r.appendChild(i),this.createFieldContainer(r)}};var Ae=class extends x{constructor(){super(...arguments);this.textareaEl=null;this.previewEl=null;this.previewModeEl=null}render(){let e=this.field,a=e.mode??"split",r=e.toolbar??!0,s=e.height??"300px",i=document.createElement("div");return i.className=`easy-form-markdown easy-form-markdown-mode-${a}`,a==="tabs"?this.renderTabsMode(i,e,r,s):a==="preview"?this.renderPreviewMode(i,e,r,s):this.renderSplitMode(i,e,r,s),this.checkAndShowDependenciesMessage(),this.createFieldContainer(i)}renderSplitMode(e,a,r,s){if(r){let d=this.createToolbar();e.appendChild(d)}let i=document.createElement("div");i.className="easy-form-markdown-editor-wrapper easy-form-markdown-split";let l=document.createElement("textarea");l.className="easy-form-markdown-textarea",l.value=this.value||"",l.placeholder=a.placeholder||"Escribe en Markdown...",l.style.height=s,this.textareaEl=l,l.addEventListener("input",()=>{this.onChange(l.value),this.updatePreview()}),l.addEventListener("blur",()=>{this.onBlur()}),i.appendChild(l),e.appendChild(i);let n=document.createElement("div");n.className="easy-form-markdown-preview",n.style.height=s,this.previewEl=n,this.value?this.renderPreview(this.value,n):n.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>',i.appendChild(n)}renderTabsMode(e,a,r,s){let i=document.createElement("div");i.className="easy-form-markdown-tabs";let l=document.createElement("div");l.className="easy-form-markdown-tabs-header";let n=document.createElement("button");n.type="button",n.className="easy-form-markdown-tab active",n.textContent="Editor",n.addEventListener("click",()=>this.switchTab("editor"));let d=document.createElement("button");d.type="button",d.className="easy-form-markdown-tab",d.textContent="Vista previa",d.addEventListener("click",()=>this.switchTab("preview")),l.appendChild(n),l.appendChild(d),i.appendChild(l);let c=document.createElement("div");if(c.className="easy-form-markdown-tabs-content",r){let u=this.createToolbar();c.appendChild(u)}let m=document.createElement("textarea");m.className="easy-form-markdown-textarea",m.value=this.value||"",m.placeholder=a.placeholder||"Escribe en Markdown...",m.style.height=s,this.textareaEl=m,m.addEventListener("input",()=>{this.onChange(m.value),d.classList.contains("active")&&this.renderPreview(m.value,this.previewEl)}),m.addEventListener("blur",()=>{this.onBlur()}),c.appendChild(m);let p=document.createElement("div");p.className="easy-form-markdown-preview",p.style.height=s,p.style.display="none",this.previewEl=p,this.value?this.renderPreview(this.value,p):p.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>',c.appendChild(p),i.appendChild(c),e.appendChild(i),i._editorTab=n,i._previewTab=d,i._textarea=m,i._preview=p}renderPreviewMode(e,a,r,s){if(r){let d=this.createToolbar();e.appendChild(d)}let i=document.createElement("div");i.className="easy-form-markdown-preview-mode",i.style.height=s,this.previewModeEl=i;let l=document.createElement("div");l.className="easy-form-markdown-preview-mode-content",this.renderPreview(this.value||"",l);let n=document.createElement("textarea");n.className="easy-form-markdown-textarea-invisible",n.value=this.value||"",n.placeholder=a.placeholder||"Escribe...",n.setAttribute("aria-label","Editor de markdown"),n.addEventListener("input",()=>{this.onChange(n.value),this.renderPreview(n.value,l)}),n.addEventListener("blur",()=>{this.onBlur()}),i.appendChild(n),i.appendChild(l),e.appendChild(i)}switchTab(e){let a=this.textareaEl?.closest(".easy-form-markdown-tabs");if(!a)return;let r=a._editorTab,s=a._previewTab,i=a._textarea,l=a._preview;e==="editor"?(r.classList.add("active"),s.classList.remove("active"),i.style.display="block",l.style.display="none"):(r.classList.remove("active"),s.classList.add("active"),i.style.display="none",l.style.display="block",i.value&&this.renderPreview(i.value,l))}createToolbar(){let e=document.createElement("div");return e.className="easy-form-markdown-toolbar",[{icon:"<strong>B</strong>",title:"Negrita",prefix:"**",suffix:"**",placeholder:"texto en negrita"},{icon:"<em>I</em>",title:"Cursiva",prefix:"_",suffix:"_",placeholder:"texto en cursiva"},{icon:"H1",title:"Encabezado 1",prefix:"# ",suffix:"",placeholder:"t\xEDtulo"},{icon:"H2",title:"Encabezado 2",prefix:"## ",suffix:"",placeholder:"t\xEDtulo"},{icon:"\u{1F517}",title:"Enlace",prefix:"[",suffix:"](url)",placeholder:"texto del enlace"},{icon:"<code></></code>",title:"C\xF3digo",prefix:"`",suffix:"`",placeholder:"c\xF3digo"},{icon:"\u{1F4F7}",title:"Imagen",prefix:"",placeholder:"texto alternativo"},{icon:"\u2022",title:"Lista",prefix:"- ",suffix:"",placeholder:"elemento"},{icon:"1.",title:"Lista numerada",prefix:"1. ",suffix:"",placeholder:"elemento"},{icon:'"',title:"Cita",prefix:"> ",suffix:"",placeholder:"cita"}].forEach(r=>{let s=document.createElement("button");s.type="button",s.className="easy-form-markdown-toolbar-btn",s.title=r.title,s.innerHTML=r.icon,s.addEventListener("click",()=>this.insertMarkdown(r.prefix,r.suffix,r.placeholder)),e.appendChild(s)}),e}insertMarkdown(e,a,r){let s=this.textareaEl;if(!s){if(this.previewModeEl){let p=this.previewModeEl.querySelector(".easy-form-markdown-textarea-invisible");p&&this.insertMarkdownToPreviewMode(p,e,a,r)}return}let i=s.selectionStart,l=s.selectionEnd,n=s.value,d=n.substring(i,l)||(r??""),c=n.substring(0,i)+e+d+a+n.substring(l);s.value=c;let m=i+e.length+d.length;s.setSelectionRange(m,m),s.focus(),this.onChange(c),this.updatePreview()}insertMarkdownToPreviewMode(e,a,r,s){let i=e.selectionStart,l=e.selectionEnd,n=e.value,d=n.substring(i,l)||(s??""),c=n.substring(0,i)+a+d+r+n.substring(l);e.value=c;let m=i+a.length+d.length;if(e.setSelectionRange(m,m),e.focus(),this.onChange(c),this.previewModeEl){let p=this.previewModeEl.querySelector(".easy-form-markdown-preview-mode-content");p&&this.renderPreview(c,p)}}updatePreview(){if(!this.previewEl)return;let e=this.textareaEl?.value||"";if(!e){this.previewEl.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>';return}this.renderPreview(e,this.previewEl)}async renderPreview(e,a){if(!e||!e.trim()){a.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>';return}a.innerHTML='<div class="easy-form-markdown-preview-loading">Cargando...</div>';try{let r=await Promise.resolve().then(()=>(Xe(),Je)),i=await(r.default||r).parse(e);a.innerHTML=i}catch{a.innerHTML=`
|
|
2544
2663
|
<div class="easy-form-markdown-error">
|
|
2545
2664
|
<strong>Vista previa no disponible</strong><br><br>
|
|
2546
2665
|
Instala <code>marked</code> para usar la vista previa:<br>
|
|
2547
2666
|
<code>npm install marked</code><br><br>
|
|
2548
2667
|
En tu app: <code>import 'marked'</code>
|
|
2549
2668
|
</div>
|
|
2550
|
-
`}}checkAndShowDependenciesMessage(){setTimeout(async()=>{if(this.previewEl)try{await Promise.resolve().then(()=>(Xe(),Je))}catch{let e=this.previewEl.querySelector(".easy-form-markdown-preview-placeholder");e&&(e.innerHTML+='<br><small style="color:#888">Instala <code>marked</code> para renderizar</small>')}},100)}};function et(o,t,e,a,r){switch(o.type){case"text":case"email":return new se(o,t,e,a,r).render();case"password":return new ye(o,t,e,a,r).render();case"number":return new ie(o,t,e,a,r).render();case"textarea":return new oe(o,t,e,a,r).render();case"select":return new ne(o,t,e,a,r).render();case"checkbox":return new le(o,t,e,a,r).render();case"radio":return new de(o,t,e,a,r).render();case"switch":return new ce(o,t,e,a,r).render();case"date":return new pe(o,t,e,a,r).render();case"file":return new me(o,t,e,a,r).render();case"file-drop":return new xe(o,t,e,a,r).render();case"map":return new ve(o,t,e,a,r).render();case"rating":return new ke(o,t,e,a,r).render();case"slider":return new we(o,t,e,a,r).render();case"colorpicker":return new Se(o,t,e,a,r).render();case"quantity":return new ue(o,t,e,a,r).render();case"accordion-select":return new fe(o,t,e,a,r).render();case"image-grid-select":return new he(o,t,e,a,r).render();case"otp":return new ge(o,t,e,a,r).render();case"markdown":return new Me(o,t,e,a,r).render();default:let s=document.createElement("div");return s.textContent=`Tipo de campo no soportado: ${o.type}`,s}}var Ot=new Map;function _t(o,t){Ot.set(o,t)}function tt(o){for(let[t,e]of Object.entries(o))_t(t,e)}function Ie(o){return Ot.get(o)}var Kr={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Enter your password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:6,message:"Password must be at least 6 characters"}]},{type:"checkbox",name:"rememberMe",label:"Remember me",defaultValue:!1}]},Qr={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"},{type:"minLength",value:2,message:"Name must be at least 2 characters"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Create a password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm Password",placeholder:"Confirm your password",validations:[{type:"required",message:"Please confirm your password"},{type:"custom",validator:o=>typeof o=="string"&&o.length>=8,message:"Password must be at least 8 characters"}]}]},Jr={fields:[{type:"otp",name:"code",label:"Verification Code",validations:[{type:"required",message:"Verification code is required"}]}]},Xr={fields:[{type:"text",name:"name",label:"Name",placeholder:"Enter your name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"subject",label:"Subject",placeholder:"Enter the subject",validations:[{type:"required",message:"Subject is required"}]},{type:"textarea",name:"message",label:"Message",placeholder:"Enter your message",rows:5,validations:[{type:"required",message:"Message is required"},{type:"minLength",value:10,message:"Message must be at least 10 characters"}]}]},ea={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email address",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]}]},ta={fields:[{type:"password",name:"currentPassword",label:"Current Password",placeholder:"Enter your current password",validations:[{type:"required",message:"Current password is required"}]},{type:"password",name:"newPassword",label:"New Password",placeholder:"Enter your new password",validations:[{type:"required",message:"New password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm New Password",placeholder:"Confirm your new password",validations:[{type:"required",message:"Please confirm your new password"},{type:"custom",validator:o=>typeof o=="string"&&o.length>=8,message:"Password must be at least 8 characters"}]}]},ra={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"phone",label:"Phone",placeholder:"Enter your phone number",mask:{type:"phone"}},{type:"textarea",name:"bio",label:"Bio",placeholder:"Tell us about yourself",rows:4},{type:"file",name:"avatar",label:"Profile Picture",accept:"image/*"}]},aa={fields:[{type:"group",name:"billingAddress",label:"Billing Address",fields:[{type:"text",name:"street",label:"Street Address",placeholder:"Enter street address",validations:[{type:"required",message:"Street address is required"}]},{type:"row",name:"cityState",fields:[{type:"text",name:"city",label:"City",placeholder:"City",validations:[{type:"required",message:"City is required"}]},{type:"text",name:"state",label:"State",placeholder:"State",validations:[{type:"required",message:"State is required"}]}]},{type:"text",name:"zipCode",label:"ZIP Code",placeholder:"ZIP Code",validations:[{type:"required",message:"ZIP code is required"}]}]},{type:"select",name:"paymentMethod",label:"Payment Method",options:[{label:"Credit Card",value:"credit-card"},{label:"Debit Card",value:"debit-card"},{label:"PayPal",value:"paypal"},{label:"Bank Transfer",value:"bank-transfer"}],validations:[{type:"required",message:"Payment method is required"}]},{type:"select",name:"shipping",label:"Shipping Method",options:[{label:"Standard (5-7 days)",value:"standard"},{label:"Express (2-3 days)",value:"express"},{label:"Overnight",value:"overnight"}],validations:[{type:"required",message:"Shipping method is required"}]}]},sa={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 - Poor",value:1},{label:"2 - Fair",value:2},{label:"3 - Good",value:3},{label:"4 - Very Good",value:4},{label:"5 - Excellent",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"textarea",name:"comment",label:"Comment",placeholder:"Share your feedback",rows:5,validations:[{type:"required",message:"Comment is required"}]},{type:"email",name:"email",label:"Email (optional)",placeholder:"Enter your email if you want a response"}]},ia={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"checkbox",name:"weeklyNewsletter",label:"Weekly Newsletter",defaultValue:!0},{type:"checkbox",name:"productUpdates",label:"Product Updates",defaultValue:!1},{type:"checkbox",name:"promotions",label:"Promotions and Special Offers",defaultValue:!1}]},oa={fields:[{type:"date",name:"date",label:"Date",validations:[{type:"required",message:"Date is required"}]},{type:"text",name:"time",label:"Time",placeholder:"HH:MM",mask:{type:"time"},validations:[{type:"required",message:"Time is required"}]},{type:"number",name:"guests",label:"Number of Guests",placeholder:"Enter number of guests",min:1,max:20,validations:[{type:"required",message:"Number of guests is required"},{type:"min",value:1,message:"At least 1 guest is required"}]},{type:"textarea",name:"specialRequests",label:"Special Requests",placeholder:"Any special requests or dietary restrictions?",rows:4}]},na={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 Star",value:1},{label:"2 Stars",value:2},{label:"3 Stars",value:3},{label:"4 Stars",value:4},{label:"5 Stars",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"text",name:"title",label:"Review Title",placeholder:"Give your review a title",validations:[{type:"required",message:"Review title is required"},{type:"minLength",value:5,message:"Title must be at least 5 characters"}]},{type:"textarea",name:"comment",label:"Your Review",placeholder:"Share your experience",rows:6,validations:[{type:"required",message:"Review comment is required"},{type:"minLength",value:20,message:"Review must be at least 20 characters"}]}]},Re={login:Kr,register:Qr,otp:Jr,contact:Xr,"password-reset":ea,"password-change":ta,profile:ra,checkout:aa,feedback:sa,subscription:ia,booking:oa,review:na};function $e(o){return o in Re?Re[o]:null}function la(){return Object.keys(Re)}function rt(o,t){let e=$e(o);if(!e)throw new Error(`Template "${o}" not found`);let a=e.fields||[],r=e.steps;if(r&&r.length>0){let s=r[r.length-1];return{...e,steps:[...r.slice(0,-1),{...s,fields:[...s.fields,...t]}]}}return{...e,fields:[...a,...t]}}var da=typeof HTMLElement<"u"?HTMLElement:class{},qe=class extends da{constructor(){if(typeof HTMLElement>"u")throw new Error("EasyForm can only be used in a browser environment");super();this.customComponents={};this.isRendering=!1;this.attemptsLock=null;this.lockCountdownInterval=null;this.slotTemplates=null;this.skipPreserveValuesOnNextRender=!1;this.persistenceConfig=null;this.persistenceDebounceTimer=null;this.pendingRestoreValues=null;this.isRestoringValues=!1;this.completeTimeInterval=null;this.timeRemaining=0;this.timerStarted=!1;this.timerExpired=!1;this.dependencyRenderTimeout=null;this.stateManager=new Z,this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["schema","template","template-extend","theme","colors","initialData","loading","disabled","max-attempts","block-duration-minutes","attempts-storage-key","submit-button","label-position","show-completed-indicator","form-direction","complete-time"]}get schema(){let e=this.getAttribute("schema");return e?this.getAttribute("template")?(console.warn('EasyForm: Cannot use both "schema" and "template" attributes. "template" will be ignored.'),q(e)):q(e):null}set schema(e){e&&this.getAttribute("template")&&(console.warn('EasyForm: Setting "schema" will remove "template" attribute.'),this.removeAttribute("template"),this.removeAttribute("template-extend")),console.log("EasyForm: Setting schema via JS",e?.fields?.map(a=>({name:a.name,type:a.type,deps:!!a.dependencies}))),e?(this.setAttribute("schema",H(e)),this.handleSchemaChange()):this.removeAttribute("schema")}get template(){let e=this.getAttribute("template");return e?(this.getAttribute("schema")&&console.warn('EasyForm: Cannot use both "template" and "schema" attributes. "schema" will be ignored.'),e):null}set template(e){e&&this.getAttribute("schema")&&(console.warn('EasyForm: Setting "template" will remove "schema" attribute.'),this.removeAttribute("schema")),e?this.setAttribute("template",e):(this.removeAttribute("template"),this.removeAttribute("template-extend"))}get templateExtend(){let e=this.getAttribute("template-extend");return e?q(e):null}set templateExtend(e){e?this.setAttribute("template-extend",H(e)):this.removeAttribute("template-extend")}get maxAttempts(){let e=this.getAttribute("max-attempts");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set maxAttempts(e){e!=null&&e>=1?this.setAttribute("max-attempts",String(e)):this.removeAttribute("max-attempts")}get blockDurationMinutes(){let e=this.getAttribute("block-duration-minutes");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set blockDurationMinutes(e){e!=null&&e>=1?this.setAttribute("block-duration-minutes",String(e)):this.removeAttribute("block-duration-minutes")}get attemptsStorageKey(){return this.getAttribute("attempts-storage-key")}set attemptsStorageKey(e){e?this.setAttribute("attempts-storage-key",e):this.removeAttribute("attempts-storage-key")}get submitButton(){let e=this.getAttribute("submit-button");if(e)try{return q(e)}catch{return null}return null}set submitButton(e){e&&typeof e=="object"?this.setAttribute("submit-button",H(e)):this.removeAttribute("submit-button")}getSubmitButtonConfig(e){let a=this.submitButton,s={...e?.submitButton,...a};return{visible:s.visible??!0,text:s.text??"Enviar",width:s.width??"auto",align:s.align??"left"}}connectedCallback(){this.setupAttemptsLock(),this.setupStyles(),(this.hasAttribute("schema")||this.schema)&&this.render()}attributeChangedCallback(e,a,r){if(e==="schema"&&r!==a&&(this.getAttribute("template")&&(console.warn('EasyForm: "schema" and "template" cannot be used together. Removing "template".'),this.removeAttribute("template"),this.removeAttribute("template-extend")),this.handleSchemaChange()),e==="template"&&r!==a&&(this.getAttribute("schema")&&(console.warn('EasyForm: "template" and "schema" cannot be used together. Removing "schema".'),this.removeAttribute("schema")),this.handleSchemaChange()),e==="template-extend"&&r!==a&&this.handleSchemaChange(),e==="initialData"&&r!==a&&this.handleSchemaChange(),(e==="theme"||e==="colors")&&r!==a&&this.setupStyles(),e==="loading"&&r!==a){let s=this.shadow.querySelector("form");this.updateLoadingOverlay(s||void 0),s&&s.querySelectorAll("input, textarea, select, button").forEach(l=>{l instanceof HTMLElement&&"disabled"in l&&(l.disabled=this.loading)})}e==="disabled"&&r!==a&&this.render(),(e==="label-position"||e==="form-direction"||e==="show-completed-indicator")&&r!==a&&this.render(),(e==="max-attempts"||e==="block-duration-minutes"||e==="attempts-storage-key")&&r!==a&&(this.setupAttemptsLock(),this.updateLockOverlay()),e==="submit-button"&&r!==a&&this.render(),e==="complete-time"&&r!==a&&(this.resetTimer(),this.completeTime&&(this.timeRemaining=this.completeTime,this.render()))}setupAttemptsLock(){let e=this.maxAttempts;if(e==null||e<1){this.attemptsLock=null;return}this.attemptsLock=new U({maxAttempts:e,blockDurationMinutes:this.blockDurationMinutes??5,storageKey:this.attemptsStorageKey??void 0,onLocked:()=>{this.updateLockOverlay()},onUnlocked:()=>{this.stopLockCountdown(),this.updateLockOverlay(),this.render()}})}handleSchemaChange(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,e){let r=this.initialData;this.stateManager.initializeSchema(e,r||void 0),this.initPersistence(e),this.render()}}getSchemaFromTemplate(e){let a=$e(e);if(!a)return console.error(`EasyForm: Template "${e}" not found`),null;let r=this.templateExtend;return r&&r.length>0?rt(e,r):a}async render(){if(!this.isRendering){this.isRendering=!0;try{let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e){let S=this.shadow.querySelector("form");S&&S.parentNode===this.shadow&&S.remove();return}let r=this.skipPreserveValuesOnNextRender,s=r?{}:this.preserveCurrentValues();this.skipPreserveValuesOnNextRender=!1;let i=this.stateManager.getWizardState();if(s&&Object.keys(s).length>0)for(let[S,k]of Object.entries(s))this.stateManager.setValueWithoutValidation(S,k);let l=this.initialData,n=i!==null,d=e.steps&&e.steps.length>0;if(!r&&(!i||!n||!d||i&&e.steps&&i.totalSteps!==e.steps.length)&&(this.stateManager.initializeSchema(e,l||void 0),n&&d&&i)){let S=this.stateManager.getWizardState();if(S&&i.totalSteps===S.totalSteps){i.currentStep>=0&&i.currentStep<S.totalSteps&&this.stateManager.goToStep(i.currentStep);for(let k of i.completedSteps)k>=0&&k<S.totalSteps&&this.stateManager.completeStep(k)}}let m=this.stateManager.getWizardState(),p=document.createElement("form");p.addEventListener("submit",S=>this.handleSubmit(S)),(this.disabled||this.loading)&&p.classList.add("easy-form-disabled");let u=this.getAttribute("form-direction"),h=e.direction??(u==="vertical"||u==="horizontal"?u:"vertical");p.classList.add(`easy-form-direction-${h}`);let g=this.getAttribute("show-completed-indicator"),f=e.completedIndicator??(g!==null&&g!=="false"),y=typeof f=="object"&&f?.position?f.position:"top";if(m)this.renderWizard(p,e);else{this.renderFields(p,e.fields||[]);let S=this.getSubmitButtonConfig(e);if(S.visible){let k=document.createElement("div");k.className="easy-form-submit-wrapper",k.style.textAlign=S.align;let F=document.createElement("button");F.type="submit",F.textContent=S.text,F.className="easy-form-submit",F.style.width=S.width,(this.disabled||this.loading)&&(F.disabled=!0),k.appendChild(F),p.appendChild(k)}}let x=null;if(f){let{completed:S,total:k}=this.getCompletedRequiredProgress(e),F=document.createElement("div");F.className="easy-form-completed-indicator",F.setAttribute("role","progressbar"),F.setAttribute("aria-valuenow",String(S)),F.setAttribute("aria-valuemin","0"),F.setAttribute("aria-valuemax",String(k)),F.setAttribute("aria-label",`Campos obligatorios completados: ${S} de ${k}`);let $=document.createElement("div");$.className="easy-form-completed-track";let Ne=document.createElement("div");Ne.className="easy-form-completed-fill",Ne.style.width=k>0?`${S/k*100}%`:"0%",$.appendChild(Ne),F.appendChild($),x=document.createElement("div"),x.className="easy-form-wrapper",y==="top"?(x.appendChild(F),x.appendChild(p)):(x.appendChild(p),x.appendChild(F))}let b=this.shadow.querySelector("form");if(b&&b.parentNode===this.shadow&&b!==p)try{b.remove()}catch(S){console.warn("Error al eliminar formulario anterior:",S)}let w=this.shadow.querySelector(".easy-form-wrapper");w&&w.remove(),this.shadow.appendChild(x||p),this.completeTime&&!this.timerExpired&&(this.renderTimerDisplay(),this.setupTimerInputListener()),this.loading&&this.updateLoadingOverlay(p),this.updateLockOverlay(p)}finally{this.isRendering=!1,this.pendingRestoreValues&&this.applyPendingRestoreValues()}}}updateLockOverlay(e){let a=this.shadow.querySelector(".easy-form-lock-overlay");if(a&&a.remove(),this.stopLockCountdown(),!this.attemptsLock?.isLocked())return;let r=e||this.shadow.querySelector("form");if(!r)return;let s=document.createElement("div");s.className="easy-form-lock-overlay";let i=document.createElement("div");i.className="easy-form-lock-message",i.setAttribute("role","alert");let l=()=>{let n=this.attemptsLock.getRemainingBlockTimeMs();if(n<=0){this.stopLockCountdown();return}let d=Math.floor(n/6e4),c=Math.floor(n%6e4/1e3),m=d>0?`${d} min ${c} s`:`${c} segundos`;i.textContent=`Demasiados intentos. Intenta de nuevo en ${m}.`};l(),s.appendChild(i),r.appendChild(s),this.lockCountdownInterval=setInterval(l,1e3)}stopLockCountdown(){this.lockCountdownInterval&&(clearInterval(this.lockCountdownInterval),this.lockCountdownInterval=null)}updateLoadingOverlay(e){let a=this.shadow.querySelector(".easy-form-loading-overlay");if(a&&a.remove(),this.loading){let r=e||this.shadow.querySelector("form");if(r){let s=document.createElement("div");s.className="easy-form-loading-overlay";let i=document.createElement("div");i.className="easy-form-loading-spinner",s.appendChild(i),r.appendChild(s)}}}preserveCurrentValues(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e)return{};let r=this.shadow.querySelector("form"),s={};if(!r)return s;let i=r.querySelectorAll("input, textarea, select");for(let l of i){let n=l.getAttribute("name");if(!n||!(this.findFieldInSchema(e,n)!==null))continue;let c;if(l instanceof HTMLInputElement)if(l.type==="checkbox")c=l.checked;else if(l.type==="radio")if(l.checked)c=l.value;else continue;else l.type==="number"?c=l.value===""?null:Number(l.value):c=l.value;else l instanceof HTMLTextAreaElement?c=l.value:l instanceof HTMLSelectElement&&(l.multiple?c=Array.from(l.selectedOptions).map(m=>m.value):c=l.value||null);c!==void 0&&(s[n]=c===""?null:c)}return s}initializeSlotTemplates(){if(this.slotTemplates!==null)return;let e=[];for(let a of Array.from(this.children))a instanceof HTMLElement&&e.push(a);if(e.length===0){this.slotTemplates=[];return}this.slotTemplates=e.map(a=>{let r=a.hasAttribute("row")?a.getAttribute("row"):null,s=r!=null&&r!==""?Number(r):NaN,i=Number.isFinite(s)?s:null;return{template:a.cloneNode(!0),row:i}})}getSlotClonesByRow(e){this.initializeSlotTemplates();let a=new Map;if(!this.slotTemplates||this.slotTemplates.length===0)return a;for(let{template:r,row:s}of this.slotTemplates){let i=typeof s=="number"?s:-1;Number.isFinite(i)||(i=-1),(i<0||i>=e)&&(i=-1);let l=r.cloneNode(!0),n=a.get(i)??[];n.push(l),a.set(i,n)}return a}applySlotDisabledState(e){if(!this.disabled&&!this.loading)return;e.classList.add("easy-form-slot-disabled"),e.querySelectorAll("input, textarea, select, button").forEach(r=>{"disabled"in r&&(r.disabled=!0)})}renderFields(e,a){if(a.length===0){let n=this.getSlotClonesByRow(0).get(-1);if(n&&n.length>0)for(let d of n)this.applySlotDisabledState(d),e.appendChild(d);return}let r=a.length,s=this.getSlotClonesByRow(r);for(let l=0;l<a.length;l++){let n=s.get(l);if(n&&n.length>0){for(let m of n)this.applySlotDisabledState(m),e.appendChild(m);s.delete(l)}let d=a[l],c=this.renderField(d);c&&e.appendChild(c)}let i=s.get(-1);if(i&&i.length>0)for(let l of i)this.applySlotDisabledState(l),e.appendChild(l)}renderField(e){let a=this.stateManager.getFieldVisibility(e.name),r=this.stateManager.getFieldEnabled(e.name);if(console.log(`Rendering field: ${e.name} (${e.type}), visible: ${a}, enabled: ${r}, hasDeps: ${!!e.dependencies}`),e.type==="group"){let f=this.renderGroup(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="row"){let f=this.renderRow(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="array"){let f=this.renderArray(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="custom"){let f=this.renderCustom(e);return f&&(a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled")),f}let s=this.stateManager.getValue(e.name),i=this.stateManager.getErrors(e.name),l=i.length>0?i[0]:void 0,n=this.disabled||this.loading,d=this.getAttribute("label-position"),c=["up","down","left","right","none"],m=e.labelPosition??(d&&c.includes(d)?d:"up"),p={...e,disabled:n||!r||e.disabled,labelPosition:m},u=Ie(e.type);if(u){let f=u({field:p,value:s,error:l,onChange:y=>this.handleFieldChange(e.name,y),onBlur:()=>this.handleFieldBlur(e.name)});return f&&!a&&(f.style.display="none",f.classList.add("easy-form-field-hidden")),f}let h=et(p,s,l,f=>this.handleFieldChange(e.name,f),()=>this.handleFieldBlur(e.name)),g=h.querySelector(".easy-form-field")||h;return g instanceof HTMLElement&&g.setAttribute("data-field-name",e.name),a||(h.style.display="none",h.classList.add("easy-form-field-hidden")),h}renderGroup(e){let a=e,r=a.direction??"vertical",s=a.collapsible===!0,i=a.defaultOpen!==!1,l=document.createElement("div");if(l.className=`easy-form-group easy-form-direction-${r}`,e.name&&l.setAttribute("data-field-name",e.name),s){l.classList.add("easy-form-group-collapsible"),i||l.classList.add("easy-form-group-collapsed");let n=document.createElement("button");n.type="button",n.className="easy-form-group-header",n.setAttribute("aria-expanded",String(i));let d=`easy-form-group-${(e.name||"group").replace(/[^a-z0-9]/gi,"-")}-content`;n.setAttribute("aria-controls",d);let c=document.createElement("span");c.textContent=e.label||"Grupo";let m=document.createElement("span");m.className="easy-form-group-chevron",m.setAttribute("aria-hidden","true"),m.textContent="\u25BC",n.appendChild(c),n.appendChild(m),l.appendChild(n);let p=document.createElement("div");if(p.id=d,p.className="easy-form-group-content","fields"in e&&e.fields)for(let h of e.fields){let g=h.name.startsWith(e.name+".")?h.name:`${e.name}.${h.name}`,f={...h,name:g},y=this.renderField(f);y&&p.appendChild(y)}l.appendChild(p);let u=h=>{h?p.style.maxHeight=p.scrollHeight+"px":p.style.maxHeight="0"};i?requestAnimationFrame(()=>u(!0)):p.style.maxHeight="0",n.addEventListener("click",()=>{l.classList.contains("easy-form-group-collapsed")?(l.classList.remove("easy-form-group-collapsed"),n.setAttribute("aria-expanded","true"),u(!0)):(p.style.maxHeight=p.scrollHeight+"px",requestAnimationFrame(()=>{l.classList.add("easy-form-group-collapsed"),n.setAttribute("aria-expanded","false"),u(!1)}))})}else{if(e.label){let n=document.createElement("h3");n.className="easy-form-group-label",n.textContent=e.label,l.appendChild(n)}if("fields"in e&&e.fields)for(let n of e.fields){let d=n.name.startsWith(e.name+".")?n.name:`${e.name}.${n.name}`,c={...n,name:d},m=this.renderField(c);m&&l.appendChild(m)}}return l}renderRow(e){let a=document.createElement("div");a.className="easy-form-row";let r=e;if(a.style.display="flex",a.style.flexWrap="wrap",a.style.alignItems=r.align||"stretch",r.gap!==void 0){let s=typeof r.gap=="number"?`${r.gap}px`:r.gap;a.style.gap=s}else a.style.gap="1rem";if("fields"in e&&e.fields)for(let s of e.fields){let i=this.renderField(s);if(i){let l=document.createElement("div");l.style.flex="1",l.style.minWidth="0",l.appendChild(i),a.appendChild(l)}}return a}renderArray(e){let a=document.createElement("div");if(a.className="easy-form-array",a.setAttribute("data-field-name",e.name),e.label){let m=document.createElement("label");m.className="easy-form-label",m.textContent=e.label,a.appendChild(m)}let r=this.stateManager.getValue(e.name)||[],s=e,i=s.minItems??0,l=s.maxItems??1/0,n=document.createElement("div");n.className="easy-form-array-items";for(let m=0;m<r.length;m++){let p=document.createElement("div");if(p.className="easy-form-array-item",s.itemSchema?.fields)for(let g of s.itemSchema.fields){let f={...g,name:`${e.name}.${m}.${g.name}`},y=this.renderField(f);y&&p.appendChild(y)}let u=document.createElement("button");u.type="button",u.textContent="Eliminar",u.className="easy-form-array-remove";let h=r.length<=i;this.disabled||this.loading||h?u.disabled=!0:u.addEventListener("click",()=>{let g=[...r];g.splice(m,1),this.handleFieldChange(e.name,g)}),p.appendChild(u),n.appendChild(p)}a.appendChild(n);let d=document.createElement("button");d.type="button",d.textContent="Agregar",d.className="easy-form-array-add";let c=r.length>=l;return this.disabled||this.loading||c?d.disabled=!0:d.addEventListener("click",()=>{let m=this.stateManager.createDefaultArrayItem(e),p=[...r,m];this.handleFieldChange(e.name,p)}),a.appendChild(d),a}renderCustom(e){let a=Ie("custom");if(!a){let l=document.createElement("div");return l.textContent=`Componente custom no registrado para: ${e.name}`,l}let r=this.stateManager.getValue(e.name),s=this.stateManager.getErrors(e.name),i=s.length>0?s[0]:void 0;return a({field:e,value:r,error:i,onChange:l=>this.handleFieldChange(e.name,l),onBlur:()=>this.handleFieldBlur(e.name)})}getCompletedRequiredProgress(e){let a=c=>{let m=[];for(let p of c)if(p.type==="array"&&"itemSchema"in p&&p.itemSchema?.fields){let u=this.stateManager.getValue(p.name),h=Array.isArray(u)?u.length:0;for(let g=0;g<h;g++)for(let f of p.itemSchema.fields)m.push({...f,name:`${p.name}.${g}.${f.name}`})}else(p.type==="group"||p.type==="row")&&"fields"in p&&p.fields?m.push(...a(p.fields)):m.push(p);return m},r=e.steps?this.stateManager.getCurrentStepFields()||[]:e.fields||[],l=a(r).filter(c=>c.validations?.some(m=>m.type==="required")).filter(c=>this.stateManager.getFieldVisibility(c.name)),n=l.length;return{completed:l.filter(c=>{if(this.stateManager.getErrors(c.name).length>0)return!1;let p=this.stateManager.getValue(c.name);return!(p==null||typeof p=="string"&&p.trim()===""||Array.isArray(p)&&p.length===0&&c.type==="array")}).length,total:n}}renderWizard(e,a){let r=this.stateManager.getWizardState();if(!r)return;let s=document.createElement("div");s.className="easy-form-wizard";let i=document.createElement("div");i.className="easy-form-wizard-steps";let l=a?.stepStyle;if(l&&l!=="default"&&i.classList.add(`ef-stepper-${l}`),a?.steps)for(let p=0;p<a.steps.length;p++){let u=document.createElement("div");u.className="easy-form-wizard-step",p===r.currentStep&&u.classList.add("active"),r.completedSteps.includes(p)&&u.classList.add("completed"),u.textContent=a.steps[p].title,i.appendChild(u)}s.appendChild(i);let n=document.createElement("div");n.className="easy-form-wizard-fields";let d=this.stateManager.getCurrentStepFields();this.renderFields(n,d),s.appendChild(n);let c=document.createElement("div");if(c.className="easy-form-wizard-nav",r.currentStep>0){let p=document.createElement("button");p.type="button",p.textContent="Anterior",p.className="easy-form-wizard-prev",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",()=>{this.stateManager.getWizardState()&&this.stateManager.previousStep()&&(this.render(),this.emitStepChange())}),c.appendChild(p)}if(r.currentStep<r.totalSteps-1){let p=document.createElement("button");p.type="button",p.textContent="Siguiente",p.className="easy-form-wizard-next",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getWizardState();if(!u)return;let h=this.stateManager.getCurrentStepFields();for(let x of h)this.stateManager.getFieldVisibility(x.name)&&await this.stateManager.validateField(x.name);let g=this.stateManager.getAllErrors(),f={};for(let x of h)g[x.name]&&g[x.name].length>0&&(f[x.name]=g[x.name]);Object.keys(f).length>0?this.emitError(f):(this.stateManager.completeStep(u.currentStep),this.stateManager.nextStep()&&(this.render(),this.emitStepChange()))}),c.appendChild(p)}let m=this.getSubmitButtonConfig(a);if(r.currentStep===r.totalSteps-1&&m.visible){let p=document.createElement("button");p.type="button",p.textContent=m.text,p.className="easy-form-wizard-next",p.style.width=m.width,this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getCurrentStepFields();for(let y of u)this.stateManager.getFieldVisibility(y.name)&&await this.stateManager.validateField(y.name);let h=this.stateManager.getAllErrors(),g={};for(let y of u)h[y.name]&&h[y.name].length>0&&(g[y.name]=h[y.name]);Object.keys(g).length>0?this.emitError(g):await this.handleSubmit(new Event("submit"))}),c.appendChild(p)}s.appendChild(c),e.appendChild(s)}async handleFieldChange(e,a){await this.stateManager.setValue(e,a),this.scheduleSave();let r=this.schema;if(r){let l=this.findFieldInSchema(r,e);l?.type==="array"&&(this.rerenderArrayField(l)||(this.skipPreserveValuesOnNextRender=!0,requestAnimationFrame(()=>this.render())))}let s=this.stateManager.getDependentFields(e);s.length>0&&(this.dependencyRenderTimeout&&clearTimeout(this.dependencyRenderTimeout),this.dependencyRenderTimeout=setTimeout(()=>{this.renderDependentFields(s),this.emitDependencyChange(e,s)},10));let i=new CustomEvent("change",{detail:{field:e,value:a,values:this.stateManager.getState().values},bubbles:!0,composed:!0});this.dispatchEvent(i)}rerenderArrayField(e){let a=this.shadow.querySelector(`[data-field-name="${e.name}"].easy-form-array`);if(!a?.parentNode)return!1;let r=this.renderArray(e);return a.parentNode.replaceChild(r,a),!0}renderDependentFields(e){let a=this.schema;if(!a)return;let r=this.getAllFieldsWithDependencies(a),s=r.length>0;console.log("renderDependentFields:",{fieldNames:e,hasAnyFieldsWithDeps:s,allFieldsWithDeps:r.map(n=>n.name)});let i=this.shadow.querySelector("form");if(!i)return;let l=new Set;for(let n of e)l.add(n);for(let n of e)this.stateManager.getDependentFields(n).forEach(c=>l.add(c));for(let n of l){let d=i.querySelector(`[data-field-name="${n}"]`);if(d||(d=i.querySelector(`.easy-form-field[name="${n}"]`)),d||(d=i.querySelector(`[data-field-name="${n}"], [data-group-name="${n}"]`)),d){let c=this.findFieldInSchema(a,n);if(!c)continue;let m=d.parentElement;if(m){let p=this.renderField(c);p&&m.replaceChild(p,d)}}}}getAllFieldsWithDependencies(e){let a=[],r=i=>{for(let l of i)l.dependencies&&a.push(l),l.type==="group"&&"fields"in l&&r(l.fields),l.type==="row"&&"fields"in l&&r(l.fields),l.type==="array"&&"itemSchema"in l&&l.itemSchema?.fields&&r(l.itemSchema.fields)},s=e.isWizard?e.steps.flatMap(i=>i.fields):e.fields||[];return r(s),a}emitDependencyChange(e,a){let r=new CustomEvent("dependencyChange",{detail:{changedField:e,affectedFields:a},bubbles:!0,composed:!0});this.dispatchEvent(r)}async handleFieldBlur(e){this.stateManager.setTouched(e),await this.stateManager.validateField(e),this.updateSingleField(e)}updateSingleField(e){let a=this.schema;if(!a||!this.findFieldInSchema(a,e))return;let s=this.stateManager.getErrors(e),i=s.length>0?s[0]:void 0,l=this.shadow.querySelector(`[name="${e}"]`)?.closest(".easy-form-field");if(!l)return;let n=l.querySelector(".easy-form-error");if(i){if(n)n.textContent=i;else{let c=document.createElement("p");c.className="easy-form-error",c.textContent=i,l.appendChild(c)}l.querySelector("input, textarea, select")?.classList.add("easy-form-input-error")}else n?.remove(),l.querySelector("input, textarea, select")?.classList.remove("easy-form-input-error")}findFieldInSchema(e,a){let r=e.fields||[],s=a.indexOf(".");if(s>0){let i=a.slice(0,s),l=a.slice(s+1),n=r.find(d=>d.name===i);if(!n)return null;if((n.type==="group"||n.type==="row")&&"fields"in n&&n.fields){let d=this.findFieldInSchema({fields:n.fields},l);return d?{...d,name:a}:null}return null}for(let i of r){if(i.name===a)return i;if(i.type==="group"&&"fields"in i){let l=this.findFieldInSchema({fields:i.fields},a);if(l)return l}if(i.type==="row"&&"fields"in i){let l=this.findFieldInSchema({fields:i.fields},a);if(l)return l}}return null}async handleSubmit(e){if(e.preventDefault(),this.attemptsLock?.isLocked())return;if(this.timerExpired){this.emitError({form:["El tiempo ha expirado. No puedes enviar el formulario."]});return}let a=await this.stateManager.validateForm(),r=this.stateManager.getState();if(Object.keys(a).length>0){for(let l of Object.keys(a))this.updateSingleField(l);this.emitError(a);return}let s={values:r.values,isValid:!0,errors:{}};this.completeTime&&this.timerStarted&&(s.timeRemaining=this.timeRemaining);let i=new CustomEvent("submit",{detail:s,bubbles:!0,composed:!0});this.dispatchEvent(i),this.clearPersistence()}emitError(e){let a=new CustomEvent("error",{detail:{errors:e},bubbles:!0,composed:!0});this.dispatchEvent(a)}emitStepChange(){let e=this.stateManager.getWizardState();if(!e)return;let a=new CustomEvent("stepChange",{detail:{currentStep:e.currentStep,previousStep:e.currentStep>0?e.currentStep-1:e.currentStep,totalSteps:e.totalSteps},bubbles:!0,composed:!0});this.dispatchEvent(a)}registerComponents(e){this.customComponents={...this.customComponents,...e},tt(e)}reset(){this.stateManager.reset(),this.render()}incrementAttempts(){this.attemptsLock?.incrementAttempts(),this.attemptsLock?.isLocked()&&this.updateLockOverlay()}resetAttempts(){this.attemptsLock?.reset(),this.stopLockCountdown(),this.updateLockOverlay(),this.render()}isLocked(){return this.attemptsLock?.isLocked()??!1}getRemainingBlockTimeMs(){return this.attemptsLock?.getRemainingBlockTimeMs()??0}requestSubmit(){let e=this.shadow.querySelector("form");e&&typeof e.requestSubmit=="function"&&e.requestSubmit()}clear(){let e=this.schema,a=this.template,r=null;a?r=this.getSchemaFromTemplate(a):r=e,r&&(this.stateManager.initializeSchema(r,{}),this.render())}getValues(){return this.stateManager.getState().values}getValue(e){return this.stateManager.getValue(e)}async setValue(e,a){await this.stateManager.setValue(e,a),this.render()}async setValues(e){for(let[a,r]of Object.entries(e))await this.stateManager.setValue(a,r);this.render()}async validate(){let e=await this.stateManager.validateForm();if(Object.keys(e).length>0){for(let a of Object.keys(e))this.updateSingleField(a);this.emitError(e)}else this.shadow.querySelectorAll(".easy-form-error").forEach(s=>s.remove()),this.shadow.querySelectorAll(".easy-form-input-error").forEach(s=>s.classList.remove("easy-form-input-error"));return e}async validateField(e){return await this.stateManager.validateField(e),this.updateSingleField(e),this.stateManager.getErrors(e)}getErrors(){return this.stateManager.getAllErrors()}getFieldErrors(e){return this.stateManager.getErrors(e)}isValid(){return this.stateManager.getState().isValid}get theme(){let e=this.getAttribute("theme");return e&&["plano","tradicional","material","rounded-shadow","lines","shadcn","chakra","mantine","glass","bordered","minimal","efc"].includes(e)?e:"plano"}set theme(e){e?this.setAttribute("theme",e):this.removeAttribute("theme")}get colors(){let e=this.getAttribute("colors");return e?q(e):null}set colors(e){e?this.setAttribute("colors",H(e)):this.removeAttribute("colors")}get initialData(){let e=this.getAttribute("initialData");return e?q(e):null}set initialData(e){e?this.setAttribute("initialData",H(e)):this.removeAttribute("initialData")}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get completeTime(){let e=this.getAttribute("complete-time");if(!e)return null;let a=parseInt(e,10);return isNaN(a)||a<=0?null:a}set completeTime(e){e!=null&&e>0?this.setAttribute("complete-time",String(e)):this.removeAttribute("complete-time")}setupStyles(){let e=this.shadow.querySelector("style");e&&e.remove();let a=this.theme,r=j(this.colors||void 0),s=te(a,r),i=document.createElement("style");i.textContent=s,this.shadow.firstChild?this.shadow.insertBefore(i,this.shadow.firstChild):this.shadow.appendChild(i)}initPersistence(e){if(!e.persistence||!e.persistence.enabled){this.persistenceConfig=null;return}this.persistenceConfig={enabled:!0,key:e.persistence.key,autoSave:e.persistence.autoSave??!0,debounce:e.persistence.debounce??500,onRestore:e.persistence.onRestore},this.restoreFromStorage()}restoreFromStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=localStorage.getItem(this.persistenceConfig.key);if(e){let a=JSON.parse(e);a&&typeof a=="object"&&(this.pendingRestoreValues=a,this.persistenceConfig.onRestore&&this.persistenceConfig.onRestore(a))}}catch(e){console.warn("EasyForm: Error restoring from localStorage:",e)}}applyPendingRestoreValues(){if(!this.pendingRestoreValues||this.isRestoringValues)return;this.isRestoringValues=!0;let e={...this.pendingRestoreValues};this.pendingRestoreValues=null;for(let[a,r]of Object.entries(e))this.stateManager.setValueWithoutValidation(a,r);this.updateInputsWithValues(e),this.isRestoringValues=!1}updateInputsWithValues(e){for(let a of Object.keys(e)){let r=this.shadow.querySelector(`[name="${a}"]`);r&&(r.value=e[a]??"")}}saveToStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=this.stateManager.getState().values;localStorage.setItem(this.persistenceConfig.key,JSON.stringify(e))}catch(e){console.warn("EasyForm: Error saving to localStorage:",e)}}scheduleSave(){!this.persistenceConfig||!this.persistenceConfig.enabled||this.persistenceConfig.autoSave&&(this.persistenceDebounceTimer&&clearTimeout(this.persistenceDebounceTimer),this.persistenceDebounceTimer=setTimeout(()=>{this.saveToStorage()},this.persistenceConfig.debounce))}clearPersistence(){if(!(!this.persistenceConfig||!this.persistenceConfig.key))try{localStorage.removeItem(this.persistenceConfig.key)}catch(e){console.warn("EasyForm: Error clearing localStorage:",e)}}resetTimer(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerStarted=!1,this.timerExpired=!1,this.completeTime&&(this.timeRemaining=this.completeTime)}startTimer(){this.timerStarted||this.timerExpired||!this.completeTime||(this.timerStarted=!0,this.timeRemaining=this.completeTime,this.updateTimerDisplay(),this.completeTimeInterval=setInterval(()=>{this.timeRemaining--,this.updateTimerDisplay(),this.timeRemaining<=0&&this.handleTimerExpired()},1e3))}updateTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");if(!e)return;let a=Math.floor(this.timeRemaining/60),r=this.timeRemaining%60,s=`${a}:${r.toString().padStart(2,"0")}`;e.textContent=s,this.timeRemaining<=30&&e.classList.add("easy-form-timer-warning"),this.timeRemaining<=10&&e.classList.add("easy-form-timer-danger")}handleTimerExpired(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerExpired=!0;let e=new CustomEvent("timeout",{detail:{originalTime:this.completeTime||0,expiredAt:new Date},bubbles:!0,composed:!0});this.dispatchEvent(e),this.disableAllFields()}disableAllFields(){let e=this.shadow.querySelector("form");if(!e)return;e.querySelectorAll("input, textarea, select, button").forEach(s=>{(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement||s instanceof HTMLButtonElement&&s.type!=="submit")&&(s.disabled=!0)}),e.classList.add("easy-form-timer-expired");let r=this.shadow.querySelector(".easy-form-timer");r&&(r.classList.add("easy-form-timer-expired"),r.textContent="Tiempo agotado")}setupTimerInputListener(){if(!this.completeTime||this.timerStarted)return;let e=this.shadow.querySelector("form");if(!e)return;let a=()=>{!this.timerStarted&&!this.timerExpired&&this.startTimer()};e.addEventListener("input",a,{once:!0})}renderTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");e&&e.remove();let a=this.shadow.querySelector("form");if(!a)return;let r=document.createElement("div");r.className="easy-form-timer";let s=this.completeTime||0,i=Math.floor(s/60),l=s%60;r.textContent=`${i}:${l.toString().padStart(2,"0")}`,a.insertBefore(r,a.firstChild)}};typeof window<"u"&&typeof customElements<"u"&&!customElements.get("easy-form")&&customElements.define("easy-form",qe);var Pe=class{constructor(){this.options={}}fields(t){return this.options.fields=t,this}steps(t){return this.options.steps=t,this}initialData(t){return this.options.initialData=t,this}submitButton(t){return this.options.submitButton=t,this}completedIndicator(t=!0){return this.options.completedIndicator=t,this}direction(t){return this.options.direction=t,this}persistence(t,e){return this.options.persistence={enabled:!0,key:t,...e},this}stepStyle(t){return this.options.stepStyle=t,this}withCompleteTime(t){return t<=0?(console.warn("EasyFormBuilder: completeTime must be greater than 0"),this):(this.options.completeTime=t,this)}build(){let t={};return this.options.fields&&this.options.fields.length>0&&(t.fields=this.options.fields),this.options.steps&&this.options.steps.length>0&&(t.steps=this.options.steps),this.options.initialData&&(t.initialData=this.options.initialData),this.options.submitButton&&(t.submitButton=this.options.submitButton),this.options.completedIndicator!==void 0&&(t.completedIndicator=this.options.completedIndicator),this.options.direction&&(t.direction=this.options.direction),this.options.persistence&&(t.persistence=this.options.persistence),this.options.stepStyle&&(t.stepStyle=this.options.stepStyle),t}};function ca(o={}){let t=new Pe;return o.fields&&t.fields(o.fields),o.steps&&t.steps(o.steps),o.initialData&&t.initialData(o.initialData),o.submitButton&&t.submitButton(o.submitButton),o.completedIndicator!==void 0&&t.completedIndicator(o.completedIndicator),o.direction&&t.direction(o.direction),o.persistence&&t.persistence(o.persistence.key,o.persistence),o.stepStyle&&t.stepStyle(o.stepStyle),o.completeTime&&t.withCompleteTime(o.completeTime),t.build()}export{U as AttemptsLock,P as ConditionEngine,qe as EasyForm,Pe as EasyFormBuilder,re as INJECTION_VALIDATION_MESSAGE,N as MaskEngine,gt as PREDEFINED_MASKS,_ as SchemaParser,Z as StateManager,Y as ValidationEngine,H as attributeValue,bt as containsInjection,ca as createFormSchema,et as createInput,rt as extendTemplate,Wa as generateId,la as getAvailableTemplates,j as getColors,Ie as getCustomComponent,I as getNestedValue,Ve as getPredefinedMask,$e as getTemplate,te as getThemeStyles,W as isSafeFromInjection,yt as isValidEmail,q as parseAttributeValue,_t as registerComponent,tt as registerComponents,Ua as sanitizeId,B as setNestedValue,Re as templates};
|
|
2669
|
+
`}}checkAndShowDependenciesMessage(){setTimeout(async()=>{try{await Promise.resolve().then(()=>(Xe(),Je))}catch{let e=this.textareaEl?.closest(".easy-form-markdown")||this.previewModeEl?.closest(".easy-form-markdown");if(!e)return;let a=e.querySelector(".easy-form-markdown-preview-placeholder");a&&(a.innerHTML+='<br><small style="color:#888">Instala <code>marked</code> para renderizar</small>')}},100)}};function et(o,t,e,a,r){switch(o.type){case"text":case"email":return new se(o,t,e,a,r).render();case"password":return new ye(o,t,e,a,r).render();case"number":return new ie(o,t,e,a,r).render();case"textarea":return new oe(o,t,e,a,r).render();case"select":return new ne(o,t,e,a,r).render();case"checkbox":return new le(o,t,e,a,r).render();case"radio":return new de(o,t,e,a,r).render();case"switch":return new ce(o,t,e,a,r).render();case"date":return new pe(o,t,e,a,r).render();case"file":return new me(o,t,e,a,r).render();case"file-drop":return new ve(o,t,e,a,r).render();case"map":return new xe(o,t,e,a,r).render();case"rating":return new ke(o,t,e,a,r).render();case"slider":return new we(o,t,e,a,r).render();case"colorpicker":return new Se(o,t,e,a,r).render();case"quantity":return new ue(o,t,e,a,r).render();case"accordion-select":return new fe(o,t,e,a,r).render();case"image-grid-select":return new he(o,t,e,a,r).render();case"otp":return new ge(o,t,e,a,r).render();case"markdown":return new Ae(o,t,e,a,r).render();default:let s=document.createElement("div");return s.textContent=`Tipo de campo no soportado: ${o.type}`,s}}var _t=new Map;function Ot(o,t){_t.set(o,t)}function tt(o){for(let[t,e]of Object.entries(o))Ot(t,e)}function Ie(o){return _t.get(o)}var Kr={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Enter your password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:6,message:"Password must be at least 6 characters"}]},{type:"checkbox",name:"rememberMe",label:"Remember me",defaultValue:!1}]},Qr={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"},{type:"minLength",value:2,message:"Name must be at least 2 characters"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Create a password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm Password",placeholder:"Confirm your password",validations:[{type:"required",message:"Please confirm your password"},{type:"custom",validator:o=>typeof o=="string"&&o.length>=8,message:"Password must be at least 8 characters"}]}]},Jr={fields:[{type:"otp",name:"code",label:"Verification Code",validations:[{type:"required",message:"Verification code is required"}]}]},Xr={fields:[{type:"text",name:"name",label:"Name",placeholder:"Enter your name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"subject",label:"Subject",placeholder:"Enter the subject",validations:[{type:"required",message:"Subject is required"}]},{type:"textarea",name:"message",label:"Message",placeholder:"Enter your message",rows:5,validations:[{type:"required",message:"Message is required"},{type:"minLength",value:10,message:"Message must be at least 10 characters"}]}]},ea={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email address",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]}]},ta={fields:[{type:"password",name:"currentPassword",label:"Current Password",placeholder:"Enter your current password",validations:[{type:"required",message:"Current password is required"}]},{type:"password",name:"newPassword",label:"New Password",placeholder:"Enter your new password",validations:[{type:"required",message:"New password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm New Password",placeholder:"Confirm your new password",validations:[{type:"required",message:"Please confirm your new password"},{type:"custom",validator:o=>typeof o=="string"&&o.length>=8,message:"Password must be at least 8 characters"}]}]},ra={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"phone",label:"Phone",placeholder:"Enter your phone number",mask:{type:"phone"}},{type:"textarea",name:"bio",label:"Bio",placeholder:"Tell us about yourself",rows:4},{type:"file",name:"avatar",label:"Profile Picture",accept:"image/*"}]},aa={fields:[{type:"group",name:"billingAddress",label:"Billing Address",fields:[{type:"text",name:"street",label:"Street Address",placeholder:"Enter street address",validations:[{type:"required",message:"Street address is required"}]},{type:"row",name:"cityState",fields:[{type:"text",name:"city",label:"City",placeholder:"City",validations:[{type:"required",message:"City is required"}]},{type:"text",name:"state",label:"State",placeholder:"State",validations:[{type:"required",message:"State is required"}]}]},{type:"text",name:"zipCode",label:"ZIP Code",placeholder:"ZIP Code",validations:[{type:"required",message:"ZIP code is required"}]}]},{type:"select",name:"paymentMethod",label:"Payment Method",options:[{label:"Credit Card",value:"credit-card"},{label:"Debit Card",value:"debit-card"},{label:"PayPal",value:"paypal"},{label:"Bank Transfer",value:"bank-transfer"}],validations:[{type:"required",message:"Payment method is required"}]},{type:"select",name:"shipping",label:"Shipping Method",options:[{label:"Standard (5-7 days)",value:"standard"},{label:"Express (2-3 days)",value:"express"},{label:"Overnight",value:"overnight"}],validations:[{type:"required",message:"Shipping method is required"}]}]},sa={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 - Poor",value:1},{label:"2 - Fair",value:2},{label:"3 - Good",value:3},{label:"4 - Very Good",value:4},{label:"5 - Excellent",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"textarea",name:"comment",label:"Comment",placeholder:"Share your feedback",rows:5,validations:[{type:"required",message:"Comment is required"}]},{type:"email",name:"email",label:"Email (optional)",placeholder:"Enter your email if you want a response"}]},ia={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"checkbox",name:"weeklyNewsletter",label:"Weekly Newsletter",defaultValue:!0},{type:"checkbox",name:"productUpdates",label:"Product Updates",defaultValue:!1},{type:"checkbox",name:"promotions",label:"Promotions and Special Offers",defaultValue:!1}]},oa={fields:[{type:"date",name:"date",label:"Date",validations:[{type:"required",message:"Date is required"}]},{type:"text",name:"time",label:"Time",placeholder:"HH:MM",mask:{type:"time"},validations:[{type:"required",message:"Time is required"}]},{type:"number",name:"guests",label:"Number of Guests",placeholder:"Enter number of guests",min:1,max:20,validations:[{type:"required",message:"Number of guests is required"},{type:"min",value:1,message:"At least 1 guest is required"}]},{type:"textarea",name:"specialRequests",label:"Special Requests",placeholder:"Any special requests or dietary restrictions?",rows:4}]},na={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 Star",value:1},{label:"2 Stars",value:2},{label:"3 Stars",value:3},{label:"4 Stars",value:4},{label:"5 Stars",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"text",name:"title",label:"Review Title",placeholder:"Give your review a title",validations:[{type:"required",message:"Review title is required"},{type:"minLength",value:5,message:"Title must be at least 5 characters"}]},{type:"textarea",name:"comment",label:"Your Review",placeholder:"Share your experience",rows:6,validations:[{type:"required",message:"Review comment is required"},{type:"minLength",value:20,message:"Review must be at least 20 characters"}]}]},Re={login:Kr,register:Qr,otp:Jr,contact:Xr,"password-reset":ea,"password-change":ta,profile:ra,checkout:aa,feedback:sa,subscription:ia,booking:oa,review:na};function $e(o){return o in Re?Re[o]:null}function la(){return Object.keys(Re)}function rt(o,t){let e=$e(o);if(!e)throw new Error(`Template "${o}" not found`);let a=e.fields||[],r=e.steps;if(r&&r.length>0){let s=r[r.length-1];return{...e,steps:[...r.slice(0,-1),{...s,fields:[...s.fields,...t]}]}}return{...e,fields:[...a,...t]}}var da=typeof HTMLElement<"u"?HTMLElement:class{},qe=class extends da{constructor(){if(typeof HTMLElement>"u")throw new Error("EasyForm can only be used in a browser environment");super();this.customComponents={};this.isRendering=!1;this.attemptsLock=null;this.lockCountdownInterval=null;this.slotTemplates=null;this.skipPreserveValuesOnNextRender=!1;this.persistenceConfig=null;this.persistenceDebounceTimer=null;this.pendingRestoreValues=null;this.isRestoringValues=!1;this.completeTimeInterval=null;this.timeRemaining=0;this.timerStarted=!1;this.timerExpired=!1;this.dependencyRenderTimeout=null;this.stateManager=new Z,this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["schema","template","template-extend","theme","colors","initialData","loading","disabled","max-attempts","block-duration-minutes","attempts-storage-key","submit-button","label-position","show-completed-indicator","form-direction","complete-time"]}get schema(){let e=this.getAttribute("schema");return e?this.getAttribute("template")?(console.warn('EasyForm: Cannot use both "schema" and "template" attributes. "template" will be ignored.'),q(e)):q(e):null}set schema(e){e&&this.getAttribute("template")&&(console.warn('EasyForm: Setting "schema" will remove "template" attribute.'),this.removeAttribute("template"),this.removeAttribute("template-extend")),console.log("EasyForm: Setting schema via JS",e?.fields?.map(a=>({name:a.name,type:a.type,deps:!!a.dependencies}))),e?(this.setAttribute("schema",H(e)),this.handleSchemaChange()):this.removeAttribute("schema")}get template(){let e=this.getAttribute("template");return e?(this.getAttribute("schema")&&console.warn('EasyForm: Cannot use both "template" and "schema" attributes. "schema" will be ignored.'),e):null}set template(e){e&&this.getAttribute("schema")&&(console.warn('EasyForm: Setting "template" will remove "schema" attribute.'),this.removeAttribute("schema")),e?this.setAttribute("template",e):(this.removeAttribute("template"),this.removeAttribute("template-extend"))}get templateExtend(){let e=this.getAttribute("template-extend");return e?q(e):null}set templateExtend(e){e?this.setAttribute("template-extend",H(e)):this.removeAttribute("template-extend")}get maxAttempts(){let e=this.getAttribute("max-attempts");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set maxAttempts(e){e!=null&&e>=1?this.setAttribute("max-attempts",String(e)):this.removeAttribute("max-attempts")}get blockDurationMinutes(){let e=this.getAttribute("block-duration-minutes");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set blockDurationMinutes(e){e!=null&&e>=1?this.setAttribute("block-duration-minutes",String(e)):this.removeAttribute("block-duration-minutes")}get attemptsStorageKey(){return this.getAttribute("attempts-storage-key")}set attemptsStorageKey(e){e?this.setAttribute("attempts-storage-key",e):this.removeAttribute("attempts-storage-key")}get submitButton(){let e=this.getAttribute("submit-button");if(e)try{return q(e)}catch{return null}return null}set submitButton(e){e&&typeof e=="object"?this.setAttribute("submit-button",H(e)):this.removeAttribute("submit-button")}getSubmitButtonConfig(e){let a=this.submitButton,s={...e?.submitButton,...a};return{visible:s.visible??!0,text:s.text??"Enviar",width:s.width??"auto",align:s.align??"left"}}connectedCallback(){this.setupAttemptsLock(),this.setupStyles(),(this.hasAttribute("schema")||this.schema)&&this.render()}attributeChangedCallback(e,a,r){if(e==="schema"&&r!==a&&(this.getAttribute("template")&&(console.warn('EasyForm: "schema" and "template" cannot be used together. Removing "template".'),this.removeAttribute("template"),this.removeAttribute("template-extend")),this.handleSchemaChange()),e==="template"&&r!==a&&(this.getAttribute("schema")&&(console.warn('EasyForm: "template" and "schema" cannot be used together. Removing "schema".'),this.removeAttribute("schema")),this.handleSchemaChange()),e==="template-extend"&&r!==a&&this.handleSchemaChange(),e==="initialData"&&r!==a&&this.handleSchemaChange(),(e==="theme"||e==="colors")&&r!==a&&this.setupStyles(),e==="loading"&&r!==a){let s=this.shadow.querySelector("form");this.updateLoadingOverlay(s||void 0),s&&s.querySelectorAll("input, textarea, select, button").forEach(l=>{l instanceof HTMLElement&&"disabled"in l&&(l.disabled=this.loading)})}e==="disabled"&&r!==a&&this.render(),(e==="label-position"||e==="form-direction"||e==="show-completed-indicator")&&r!==a&&this.render(),(e==="max-attempts"||e==="block-duration-minutes"||e==="attempts-storage-key")&&r!==a&&(this.setupAttemptsLock(),this.updateLockOverlay()),e==="submit-button"&&r!==a&&this.render(),e==="complete-time"&&r!==a&&(this.resetTimer(),this.completeTime&&(this.timeRemaining=this.completeTime,this.render()))}setupAttemptsLock(){let e=this.maxAttempts;if(e==null||e<1){this.attemptsLock=null;return}this.attemptsLock=new U({maxAttempts:e,blockDurationMinutes:this.blockDurationMinutes??5,storageKey:this.attemptsStorageKey??void 0,onLocked:()=>{this.updateLockOverlay()},onUnlocked:()=>{this.stopLockCountdown(),this.updateLockOverlay(),this.render()}})}handleSchemaChange(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,e){let r=this.initialData;this.stateManager.initializeSchema(e,r||void 0),this.initPersistence(e),this.render()}}getSchemaFromTemplate(e){let a=$e(e);if(!a)return console.error(`EasyForm: Template "${e}" not found`),null;let r=this.templateExtend;return r&&r.length>0?rt(e,r):a}async render(){if(!this.isRendering){this.isRendering=!0;try{let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e){let S=this.shadow.querySelector("form");S&&S.parentNode===this.shadow&&S.remove();return}let r=this.skipPreserveValuesOnNextRender,s=r?{}:this.preserveCurrentValues();this.skipPreserveValuesOnNextRender=!1;let i=this.stateManager.getWizardState();if(s&&Object.keys(s).length>0)for(let[S,k]of Object.entries(s))this.stateManager.setValueWithoutValidation(S,k);let l=this.initialData,n=i!==null,d=e.steps&&e.steps.length>0;if(!r&&(!i||!n||!d||i&&e.steps&&i.totalSteps!==e.steps.length)&&(this.stateManager.initializeSchema(e,l||void 0),n&&d&&i)){let S=this.stateManager.getWizardState();if(S&&i.totalSteps===S.totalSteps){i.currentStep>=0&&i.currentStep<S.totalSteps&&this.stateManager.goToStep(i.currentStep);for(let k of i.completedSteps)k>=0&&k<S.totalSteps&&this.stateManager.completeStep(k)}}let m=this.stateManager.getWizardState(),p=document.createElement("form");p.addEventListener("submit",S=>this.handleSubmit(S)),(this.disabled||this.loading)&&p.classList.add("easy-form-disabled");let u=this.getAttribute("form-direction"),h=e.direction??(u==="vertical"||u==="horizontal"?u:"vertical");p.classList.add(`easy-form-direction-${h}`);let g=this.getAttribute("show-completed-indicator"),f=e.completedIndicator??(g!==null&&g!=="false"),y=typeof f=="object"&&f?.position?f.position:"top";if(m)this.renderWizard(p,e);else{this.renderFields(p,e.fields||[]);let S=this.getSubmitButtonConfig(e);if(S.visible){let k=document.createElement("div");k.className="easy-form-submit-wrapper",k.style.textAlign=S.align;let F=document.createElement("button");F.type="submit",F.textContent=S.text,F.className="easy-form-submit",F.style.width=S.width,(this.disabled||this.loading)&&(F.disabled=!0),k.appendChild(F),p.appendChild(k)}}let v=null;if(f){let{completed:S,total:k}=this.getCompletedRequiredProgress(e),F=document.createElement("div");F.className="easy-form-completed-indicator",F.setAttribute("role","progressbar"),F.setAttribute("aria-valuenow",String(S)),F.setAttribute("aria-valuemin","0"),F.setAttribute("aria-valuemax",String(k)),F.setAttribute("aria-label",`Campos obligatorios completados: ${S} de ${k}`);let $=document.createElement("div");$.className="easy-form-completed-track";let Ne=document.createElement("div");Ne.className="easy-form-completed-fill",Ne.style.width=k>0?`${S/k*100}%`:"0%",$.appendChild(Ne),F.appendChild($),v=document.createElement("div"),v.className="easy-form-wrapper",y==="top"?(v.appendChild(F),v.appendChild(p)):(v.appendChild(p),v.appendChild(F))}let b=this.shadow.querySelector("form");if(b&&b.parentNode===this.shadow&&b!==p)try{b.remove()}catch(S){console.warn("Error al eliminar formulario anterior:",S)}let w=this.shadow.querySelector(".easy-form-wrapper");w&&w.remove(),this.shadow.appendChild(v||p),this.completeTime&&!this.timerExpired&&(this.renderTimerDisplay(),this.setupTimerInputListener()),this.loading&&this.updateLoadingOverlay(p),this.updateLockOverlay(p)}finally{this.isRendering=!1,this.pendingRestoreValues&&this.applyPendingRestoreValues()}}}updateLockOverlay(e){let a=this.shadow.querySelector(".easy-form-lock-overlay");if(a&&a.remove(),this.stopLockCountdown(),!this.attemptsLock?.isLocked())return;let r=e||this.shadow.querySelector("form");if(!r)return;let s=document.createElement("div");s.className="easy-form-lock-overlay";let i=document.createElement("div");i.className="easy-form-lock-message",i.setAttribute("role","alert");let l=()=>{let n=this.attemptsLock.getRemainingBlockTimeMs();if(n<=0){this.stopLockCountdown();return}let d=Math.floor(n/6e4),c=Math.floor(n%6e4/1e3),m=d>0?`${d} min ${c} s`:`${c} segundos`;i.textContent=`Demasiados intentos. Intenta de nuevo en ${m}.`};l(),s.appendChild(i),r.appendChild(s),this.lockCountdownInterval=setInterval(l,1e3)}stopLockCountdown(){this.lockCountdownInterval&&(clearInterval(this.lockCountdownInterval),this.lockCountdownInterval=null)}updateLoadingOverlay(e){let a=this.shadow.querySelector(".easy-form-loading-overlay");if(a&&a.remove(),this.loading){let r=e||this.shadow.querySelector("form");if(r){let s=document.createElement("div");s.className="easy-form-loading-overlay";let i=document.createElement("div");i.className="easy-form-loading-spinner",s.appendChild(i),r.appendChild(s)}}}preserveCurrentValues(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e)return{};let r=this.shadow.querySelector("form"),s={};if(!r)return s;let i=r.querySelectorAll("input, textarea, select");for(let l of i){let n=l.getAttribute("name");if(!n||!(this.findFieldInSchema(e,n)!==null))continue;let c;if(l instanceof HTMLInputElement)if(l.type==="checkbox")c=l.checked;else if(l.type==="radio")if(l.checked)c=l.value;else continue;else l.type==="number"?c=l.value===""?null:Number(l.value):c=l.value;else l instanceof HTMLTextAreaElement?c=l.value:l instanceof HTMLSelectElement&&(l.multiple?c=Array.from(l.selectedOptions).map(m=>m.value):c=l.value||null);c!==void 0&&(s[n]=c===""?null:c)}return s}initializeSlotTemplates(){if(this.slotTemplates!==null)return;let e=[];for(let a of Array.from(this.children))a instanceof HTMLElement&&e.push(a);if(e.length===0){this.slotTemplates=[];return}this.slotTemplates=e.map(a=>{let r=a.hasAttribute("row")?a.getAttribute("row"):null,s=r!=null&&r!==""?Number(r):NaN,i=Number.isFinite(s)?s:null;return{template:a.cloneNode(!0),row:i}})}getSlotClonesByRow(e){this.initializeSlotTemplates();let a=new Map;if(!this.slotTemplates||this.slotTemplates.length===0)return a;for(let{template:r,row:s}of this.slotTemplates){let i=typeof s=="number"?s:-1;Number.isFinite(i)||(i=-1),(i<0||i>=e)&&(i=-1);let l=r.cloneNode(!0),n=a.get(i)??[];n.push(l),a.set(i,n)}return a}applySlotDisabledState(e){if(!this.disabled&&!this.loading)return;e.classList.add("easy-form-slot-disabled"),e.querySelectorAll("input, textarea, select, button").forEach(r=>{"disabled"in r&&(r.disabled=!0)})}renderFields(e,a){if(a.length===0){let n=this.getSlotClonesByRow(0).get(-1);if(n&&n.length>0)for(let d of n)this.applySlotDisabledState(d),e.appendChild(d);return}let r=a.length,s=this.getSlotClonesByRow(r);for(let l=0;l<a.length;l++){let n=s.get(l);if(n&&n.length>0){for(let m of n)this.applySlotDisabledState(m),e.appendChild(m);s.delete(l)}let d=a[l],c=this.renderField(d);c&&e.appendChild(c)}let i=s.get(-1);if(i&&i.length>0)for(let l of i)this.applySlotDisabledState(l),e.appendChild(l)}renderField(e){let a=this.stateManager.getFieldVisibility(e.name),r=this.stateManager.getFieldEnabled(e.name);if(console.log(`Rendering field: ${e.name} (${e.type}), visible: ${a}, enabled: ${r}, hasDeps: ${!!e.dependencies}`),e.type==="group"){let f=this.renderGroup(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="row"){let f=this.renderRow(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="array"){let f=this.renderArray(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="custom"){let f=this.renderCustom(e);return f&&(a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled")),f}let s=this.stateManager.getValue(e.name),i=this.stateManager.getErrors(e.name),l=i.length>0?i[0]:void 0,n=this.disabled||this.loading,d=this.getAttribute("label-position"),c=["up","down","left","right","none"],m=e.labelPosition??(d&&c.includes(d)?d:"up"),p={...e,disabled:n||!r||e.disabled,labelPosition:m},u=Ie(e.type);if(u){let f=u({field:p,value:s,error:l,onChange:y=>this.handleFieldChange(e.name,y),onBlur:()=>this.handleFieldBlur(e.name)});return f&&!a&&(f.style.display="none",f.classList.add("easy-form-field-hidden")),f}let h=et(p,s,l,f=>this.handleFieldChange(e.name,f),()=>this.handleFieldBlur(e.name)),g=h.querySelector(".easy-form-field")||h;return g instanceof HTMLElement&&g.setAttribute("data-field-name",e.name),a||(h.style.display="none",h.classList.add("easy-form-field-hidden")),h}renderGroup(e){let a=e,r=a.direction??"vertical",s=a.collapsible===!0,i=a.defaultOpen!==!1,l=document.createElement("div");if(l.className=`easy-form-group easy-form-direction-${r}`,e.name&&l.setAttribute("data-field-name",e.name),s){l.classList.add("easy-form-group-collapsible"),i||l.classList.add("easy-form-group-collapsed");let n=document.createElement("button");n.type="button",n.className="easy-form-group-header",n.setAttribute("aria-expanded",String(i));let d=`easy-form-group-${(e.name||"group").replace(/[^a-z0-9]/gi,"-")}-content`;n.setAttribute("aria-controls",d);let c=document.createElement("span");c.textContent=e.label||"Grupo";let m=document.createElement("span");m.className="easy-form-group-chevron",m.setAttribute("aria-hidden","true"),m.textContent="\u25BC",n.appendChild(c),n.appendChild(m),l.appendChild(n);let p=document.createElement("div");if(p.id=d,p.className="easy-form-group-content","fields"in e&&e.fields)for(let h of e.fields){let g=h.name.startsWith(e.name+".")?h.name:`${e.name}.${h.name}`,f={...h,name:g},y=this.renderField(f);y&&p.appendChild(y)}l.appendChild(p);let u=h=>{h?p.style.maxHeight=p.scrollHeight+"px":p.style.maxHeight="0"};i?requestAnimationFrame(()=>u(!0)):p.style.maxHeight="0",n.addEventListener("click",()=>{l.classList.contains("easy-form-group-collapsed")?(l.classList.remove("easy-form-group-collapsed"),n.setAttribute("aria-expanded","true"),u(!0)):(p.style.maxHeight=p.scrollHeight+"px",requestAnimationFrame(()=>{l.classList.add("easy-form-group-collapsed"),n.setAttribute("aria-expanded","false"),u(!1)}))})}else{if(e.label){let n=document.createElement("h3");n.className="easy-form-group-label",n.textContent=e.label,l.appendChild(n)}if("fields"in e&&e.fields)for(let n of e.fields){let d=n.name.startsWith(e.name+".")?n.name:`${e.name}.${n.name}`,c={...n,name:d},m=this.renderField(c);m&&l.appendChild(m)}}return l}renderRow(e){let a=document.createElement("div");a.className="easy-form-row";let r=e;if(a.style.display="flex",a.style.flexWrap="wrap",a.style.alignItems=r.align||"stretch",r.gap!==void 0){let s=typeof r.gap=="number"?`${r.gap}px`:r.gap;a.style.gap=s}else a.style.gap="1rem";if("fields"in e&&e.fields)for(let s of e.fields){let i=this.renderField(s);if(i){let l=document.createElement("div");l.style.flex="1",l.style.minWidth="0",l.appendChild(i),a.appendChild(l)}}return a}renderArray(e){let a=document.createElement("div");if(a.className="easy-form-array",a.setAttribute("data-field-name",e.name),e.label){let m=document.createElement("label");m.className="easy-form-label",m.textContent=e.label,a.appendChild(m)}let r=this.stateManager.getValue(e.name)||[],s=e,i=s.minItems??0,l=s.maxItems??1/0,n=document.createElement("div");n.className="easy-form-array-items";for(let m=0;m<r.length;m++){let p=document.createElement("div");if(p.className="easy-form-array-item",s.itemSchema?.fields)for(let g of s.itemSchema.fields){let f={...g,name:`${e.name}.${m}.${g.name}`},y=this.renderField(f);y&&p.appendChild(y)}let u=document.createElement("button");u.type="button",u.textContent="Eliminar",u.className="easy-form-array-remove";let h=r.length<=i;this.disabled||this.loading||h?u.disabled=!0:u.addEventListener("click",()=>{let g=[...r];g.splice(m,1),this.handleFieldChange(e.name,g)}),p.appendChild(u),n.appendChild(p)}a.appendChild(n);let d=document.createElement("button");d.type="button",d.textContent="Agregar",d.className="easy-form-array-add";let c=r.length>=l;return this.disabled||this.loading||c?d.disabled=!0:d.addEventListener("click",()=>{let m=this.stateManager.createDefaultArrayItem(e),p=[...r,m];this.handleFieldChange(e.name,p)}),a.appendChild(d),a}renderCustom(e){let a=Ie("custom");if(!a){let l=document.createElement("div");return l.textContent=`Componente custom no registrado para: ${e.name}`,l}let r=this.stateManager.getValue(e.name),s=this.stateManager.getErrors(e.name),i=s.length>0?s[0]:void 0;return a({field:e,value:r,error:i,onChange:l=>this.handleFieldChange(e.name,l),onBlur:()=>this.handleFieldBlur(e.name)})}getCompletedRequiredProgress(e){let a=c=>{let m=[];for(let p of c)if(p.type==="array"&&"itemSchema"in p&&p.itemSchema?.fields){let u=this.stateManager.getValue(p.name),h=Array.isArray(u)?u.length:0;for(let g=0;g<h;g++)for(let f of p.itemSchema.fields)m.push({...f,name:`${p.name}.${g}.${f.name}`})}else(p.type==="group"||p.type==="row")&&"fields"in p&&p.fields?m.push(...a(p.fields)):m.push(p);return m},r=e.steps?this.stateManager.getCurrentStepFields()||[]:e.fields||[],l=a(r).filter(c=>c.validations?.some(m=>m.type==="required")).filter(c=>this.stateManager.getFieldVisibility(c.name)),n=l.length;return{completed:l.filter(c=>{if(this.stateManager.getErrors(c.name).length>0)return!1;let p=this.stateManager.getValue(c.name);return!(p==null||typeof p=="string"&&p.trim()===""||Array.isArray(p)&&p.length===0&&c.type==="array")}).length,total:n}}renderWizard(e,a){let r=this.stateManager.getWizardState();if(!r)return;let s=document.createElement("div");s.className="easy-form-wizard";let i=document.createElement("div");i.className="easy-form-wizard-steps";let l=a?.stepStyle;if(l&&l!=="default"&&i.classList.add(`ef-stepper-${l}`),a?.steps)for(let p=0;p<a.steps.length;p++){let u=document.createElement("div");u.className="easy-form-wizard-step",p===r.currentStep&&u.classList.add("active"),r.completedSteps.includes(p)&&u.classList.add("completed"),u.textContent=a.steps[p].title,i.appendChild(u)}s.appendChild(i);let n=document.createElement("div");n.className="easy-form-wizard-fields";let d=this.stateManager.getCurrentStepFields();this.renderFields(n,d),s.appendChild(n);let c=document.createElement("div");if(c.className="easy-form-wizard-nav",r.currentStep>0){let p=document.createElement("button");p.type="button",p.textContent="Anterior",p.className="easy-form-wizard-prev",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",()=>{this.stateManager.getWizardState()&&this.stateManager.previousStep()&&(this.render(),this.emitStepChange())}),c.appendChild(p)}if(r.currentStep<r.totalSteps-1){let p=document.createElement("button");p.type="button",p.textContent="Siguiente",p.className="easy-form-wizard-next",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getWizardState();if(!u)return;let h=this.stateManager.getCurrentStepFields();for(let v of h)this.stateManager.getFieldVisibility(v.name)&&await this.stateManager.validateField(v.name);let g=this.stateManager.getAllErrors(),f={};for(let v of h)g[v.name]&&g[v.name].length>0&&(f[v.name]=g[v.name]);Object.keys(f).length>0?this.emitError(f):(this.stateManager.completeStep(u.currentStep),this.stateManager.nextStep()&&(this.render(),this.emitStepChange()))}),c.appendChild(p)}let m=this.getSubmitButtonConfig(a);if(r.currentStep===r.totalSteps-1&&m.visible){let p=document.createElement("button");p.type="button",p.textContent=m.text,p.className="easy-form-wizard-next",p.style.width=m.width,this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getCurrentStepFields();for(let y of u)this.stateManager.getFieldVisibility(y.name)&&await this.stateManager.validateField(y.name);let h=this.stateManager.getAllErrors(),g={};for(let y of u)h[y.name]&&h[y.name].length>0&&(g[y.name]=h[y.name]);Object.keys(g).length>0?this.emitError(g):await this.handleSubmit(new Event("submit"))}),c.appendChild(p)}s.appendChild(c),e.appendChild(s)}async handleFieldChange(e,a){await this.stateManager.setValue(e,a),this.scheduleSave();let r=this.schema;if(r){let l=this.findFieldInSchema(r,e);l?.type==="array"&&(this.rerenderArrayField(l)||(this.skipPreserveValuesOnNextRender=!0,requestAnimationFrame(()=>this.render())))}let s=this.stateManager.getDependentFields(e);s.length>0&&(this.dependencyRenderTimeout&&clearTimeout(this.dependencyRenderTimeout),this.dependencyRenderTimeout=setTimeout(()=>{this.renderDependentFields(s),this.emitDependencyChange(e,s)},10));let i=new CustomEvent("change",{detail:{field:e,value:a,values:this.stateManager.getState().values},bubbles:!0,composed:!0});this.dispatchEvent(i)}rerenderArrayField(e){let a=this.shadow.querySelector(`[data-field-name="${e.name}"].easy-form-array`);if(!a?.parentNode)return!1;let r=this.renderArray(e);return a.parentNode.replaceChild(r,a),!0}renderDependentFields(e){let a=this.schema;if(!a)return;let r=this.getAllFieldsWithDependencies(a),s=r.length>0;console.log("renderDependentFields:",{fieldNames:e,hasAnyFieldsWithDeps:s,allFieldsWithDeps:r.map(n=>n.name)});let i=this.shadow.querySelector("form");if(!i)return;let l=new Set;for(let n of e)l.add(n);for(let n of e)this.stateManager.getDependentFields(n).forEach(c=>l.add(c));for(let n of l){let d=i.querySelector(`[data-field-name="${n}"]`);if(d||(d=i.querySelector(`.easy-form-field[name="${n}"]`)),d||(d=i.querySelector(`[data-field-name="${n}"], [data-group-name="${n}"]`)),d){let c=this.findFieldInSchema(a,n);if(!c)continue;let m=d.parentElement;if(m){let p=this.renderField(c);p&&m.replaceChild(p,d)}}}}getAllFieldsWithDependencies(e){let a=[],r=i=>{for(let l of i)l.dependencies&&a.push(l),l.type==="group"&&"fields"in l&&r(l.fields),l.type==="row"&&"fields"in l&&r(l.fields),l.type==="array"&&"itemSchema"in l&&l.itemSchema?.fields&&r(l.itemSchema.fields)},s=e.isWizard?e.steps.flatMap(i=>i.fields):e.fields||[];return r(s),a}emitDependencyChange(e,a){let r=new CustomEvent("dependencyChange",{detail:{changedField:e,affectedFields:a},bubbles:!0,composed:!0});this.dispatchEvent(r)}async handleFieldBlur(e){this.stateManager.setTouched(e),await this.stateManager.validateField(e),this.updateSingleField(e)}updateSingleField(e){let a=this.schema;if(!a||!this.findFieldInSchema(a,e))return;let s=this.stateManager.getErrors(e),i=s.length>0?s[0]:void 0,l=this.shadow.querySelector(`[name="${e}"]`)?.closest(".easy-form-field");if(!l)return;let n=l.querySelector(".easy-form-error");if(i){if(n)n.textContent=i;else{let c=document.createElement("p");c.className="easy-form-error",c.textContent=i,l.appendChild(c)}l.querySelector("input, textarea, select")?.classList.add("easy-form-input-error")}else n?.remove(),l.querySelector("input, textarea, select")?.classList.remove("easy-form-input-error")}findFieldInSchema(e,a){let r=e.fields||[],s=a.indexOf(".");if(s>0){let i=a.slice(0,s),l=a.slice(s+1),n=r.find(d=>d.name===i);if(!n)return null;if((n.type==="group"||n.type==="row")&&"fields"in n&&n.fields){let d=this.findFieldInSchema({fields:n.fields},l);return d?{...d,name:a}:null}return null}for(let i of r){if(i.name===a)return i;if(i.type==="group"&&"fields"in i){let l=this.findFieldInSchema({fields:i.fields},a);if(l)return l}if(i.type==="row"&&"fields"in i){let l=this.findFieldInSchema({fields:i.fields},a);if(l)return l}}return null}async handleSubmit(e){if(e.preventDefault(),this.attemptsLock?.isLocked())return;if(this.timerExpired){this.emitError({form:["El tiempo ha expirado. No puedes enviar el formulario."]});return}let a=await this.stateManager.validateForm(),r=this.stateManager.getState();if(Object.keys(a).length>0){for(let l of Object.keys(a))this.updateSingleField(l);this.emitError(a);return}let s={values:r.values,isValid:!0,errors:{}};this.completeTime&&this.timerStarted&&(s.timeRemaining=this.timeRemaining);let i=new CustomEvent("submit",{detail:s,bubbles:!0,composed:!0});this.dispatchEvent(i),this.clearPersistence()}emitError(e){let a=new CustomEvent("error",{detail:{errors:e},bubbles:!0,composed:!0});this.dispatchEvent(a)}emitStepChange(){let e=this.stateManager.getWizardState();if(!e)return;let a=new CustomEvent("stepChange",{detail:{currentStep:e.currentStep,previousStep:e.currentStep>0?e.currentStep-1:e.currentStep,totalSteps:e.totalSteps},bubbles:!0,composed:!0});this.dispatchEvent(a)}registerComponents(e){this.customComponents={...this.customComponents,...e},tt(e)}reset(){this.stateManager.reset(),this.render()}incrementAttempts(){this.attemptsLock?.incrementAttempts(),this.attemptsLock?.isLocked()&&this.updateLockOverlay()}resetAttempts(){this.attemptsLock?.reset(),this.stopLockCountdown(),this.updateLockOverlay(),this.render()}isLocked(){return this.attemptsLock?.isLocked()??!1}getRemainingBlockTimeMs(){return this.attemptsLock?.getRemainingBlockTimeMs()??0}requestSubmit(){let e=this.shadow.querySelector("form");e&&typeof e.requestSubmit=="function"&&e.requestSubmit()}clear(){let e=this.schema,a=this.template,r=null;a?r=this.getSchemaFromTemplate(a):r=e,r&&(this.stateManager.initializeSchema(r,{}),this.render())}getValues(){return this.stateManager.getState().values}getValue(e){return this.stateManager.getValue(e)}async setValue(e,a){await this.stateManager.setValue(e,a),this.render()}async setValues(e){for(let[a,r]of Object.entries(e))await this.stateManager.setValue(a,r);this.render()}async validate(){let e=await this.stateManager.validateForm();if(Object.keys(e).length>0){for(let a of Object.keys(e))this.updateSingleField(a);this.emitError(e)}else this.shadow.querySelectorAll(".easy-form-error").forEach(s=>s.remove()),this.shadow.querySelectorAll(".easy-form-input-error").forEach(s=>s.classList.remove("easy-form-input-error"));return e}async validateField(e){return await this.stateManager.validateField(e),this.updateSingleField(e),this.stateManager.getErrors(e)}getErrors(){return this.stateManager.getAllErrors()}getFieldErrors(e){return this.stateManager.getErrors(e)}isValid(){return this.stateManager.getState().isValid}get theme(){let e=this.getAttribute("theme");return e&&["plano","tradicional","material","rounded-shadow","lines","shadcn","chakra","mantine","glass","bordered","minimal","efc"].includes(e)?e:"plano"}set theme(e){e?this.setAttribute("theme",e):this.removeAttribute("theme")}get colors(){let e=this.getAttribute("colors");return e?q(e):null}set colors(e){e?this.setAttribute("colors",H(e)):this.removeAttribute("colors")}get initialData(){let e=this.getAttribute("initialData");return e?q(e):null}set initialData(e){e?this.setAttribute("initialData",H(e)):this.removeAttribute("initialData")}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get completeTime(){let e=this.getAttribute("complete-time");if(!e)return null;let a=parseInt(e,10);return isNaN(a)||a<=0?null:a}set completeTime(e){e!=null&&e>0?this.setAttribute("complete-time",String(e)):this.removeAttribute("complete-time")}setupStyles(){let e=this.shadow.querySelector("style");e&&e.remove();let a=this.theme,r=j(this.colors||void 0),s=te(a,r),i=document.createElement("style");i.textContent=s,this.shadow.firstChild?this.shadow.insertBefore(i,this.shadow.firstChild):this.shadow.appendChild(i)}initPersistence(e){if(!e.persistence||!e.persistence.enabled){this.persistenceConfig=null;return}this.persistenceConfig={enabled:!0,key:e.persistence.key,autoSave:e.persistence.autoSave??!0,debounce:e.persistence.debounce??500,onRestore:e.persistence.onRestore},this.restoreFromStorage()}restoreFromStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=localStorage.getItem(this.persistenceConfig.key);if(e){let a=JSON.parse(e);a&&typeof a=="object"&&(this.pendingRestoreValues=a,this.persistenceConfig.onRestore&&this.persistenceConfig.onRestore(a))}}catch(e){console.warn("EasyForm: Error restoring from localStorage:",e)}}applyPendingRestoreValues(){if(!this.pendingRestoreValues||this.isRestoringValues)return;this.isRestoringValues=!0;let e={...this.pendingRestoreValues};this.pendingRestoreValues=null;for(let[a,r]of Object.entries(e))this.stateManager.setValueWithoutValidation(a,r);this.updateInputsWithValues(e),this.isRestoringValues=!1}updateInputsWithValues(e){for(let a of Object.keys(e)){let r=this.shadow.querySelector(`[name="${a}"]`);r&&(r.value=e[a]??"")}}saveToStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=this.stateManager.getState().values;localStorage.setItem(this.persistenceConfig.key,JSON.stringify(e))}catch(e){console.warn("EasyForm: Error saving to localStorage:",e)}}scheduleSave(){!this.persistenceConfig||!this.persistenceConfig.enabled||this.persistenceConfig.autoSave&&(this.persistenceDebounceTimer&&clearTimeout(this.persistenceDebounceTimer),this.persistenceDebounceTimer=setTimeout(()=>{this.saveToStorage()},this.persistenceConfig.debounce))}clearPersistence(){if(!(!this.persistenceConfig||!this.persistenceConfig.key))try{localStorage.removeItem(this.persistenceConfig.key)}catch(e){console.warn("EasyForm: Error clearing localStorage:",e)}}resetTimer(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerStarted=!1,this.timerExpired=!1,this.completeTime&&(this.timeRemaining=this.completeTime)}startTimer(){this.timerStarted||this.timerExpired||!this.completeTime||(this.timerStarted=!0,this.timeRemaining=this.completeTime,this.updateTimerDisplay(),this.completeTimeInterval=setInterval(()=>{this.timeRemaining--,this.updateTimerDisplay(),this.timeRemaining<=0&&this.handleTimerExpired()},1e3))}updateTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");if(!e)return;let a=Math.floor(this.timeRemaining/60),r=this.timeRemaining%60,s=`${a}:${r.toString().padStart(2,"0")}`;e.textContent=s,this.timeRemaining<=30&&e.classList.add("easy-form-timer-warning"),this.timeRemaining<=10&&e.classList.add("easy-form-timer-danger")}handleTimerExpired(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerExpired=!0;let e=new CustomEvent("timeout",{detail:{originalTime:this.completeTime||0,expiredAt:new Date},bubbles:!0,composed:!0});this.dispatchEvent(e),this.disableAllFields()}disableAllFields(){let e=this.shadow.querySelector("form");if(!e)return;e.querySelectorAll("input, textarea, select, button").forEach(s=>{(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement||s instanceof HTMLButtonElement&&s.type!=="submit")&&(s.disabled=!0)}),e.classList.add("easy-form-timer-expired");let r=this.shadow.querySelector(".easy-form-timer");r&&(r.classList.add("easy-form-timer-expired"),r.textContent="Tiempo agotado")}setupTimerInputListener(){if(!this.completeTime||this.timerStarted)return;let e=this.shadow.querySelector("form");if(!e)return;let a=()=>{!this.timerStarted&&!this.timerExpired&&this.startTimer()};e.addEventListener("input",a,{once:!0})}renderTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");e&&e.remove();let a=this.shadow.querySelector("form");if(!a)return;let r=document.createElement("div");r.className="easy-form-timer";let s=this.completeTime||0,i=Math.floor(s/60),l=s%60;r.textContent=`${i}:${l.toString().padStart(2,"0")}`,a.insertBefore(r,a.firstChild)}};typeof window<"u"&&typeof customElements<"u"&&!customElements.get("easy-form")&&customElements.define("easy-form",qe);var Pe=class{constructor(){this.options={}}fields(t){return this.options.fields=t,this}steps(t){return this.options.steps=t,this}initialData(t){return this.options.initialData=t,this}submitButton(t){return this.options.submitButton=t,this}completedIndicator(t=!0){return this.options.completedIndicator=t,this}direction(t){return this.options.direction=t,this}persistence(t,e){return this.options.persistence={enabled:!0,key:t,...e},this}stepStyle(t){return this.options.stepStyle=t,this}withCompleteTime(t){return t<=0?(console.warn("EasyFormBuilder: completeTime must be greater than 0"),this):(this.options.completeTime=t,this)}build(){let t={};return this.options.fields&&this.options.fields.length>0&&(t.fields=this.options.fields),this.options.steps&&this.options.steps.length>0&&(t.steps=this.options.steps),this.options.initialData&&(t.initialData=this.options.initialData),this.options.submitButton&&(t.submitButton=this.options.submitButton),this.options.completedIndicator!==void 0&&(t.completedIndicator=this.options.completedIndicator),this.options.direction&&(t.direction=this.options.direction),this.options.persistence&&(t.persistence=this.options.persistence),this.options.stepStyle&&(t.stepStyle=this.options.stepStyle),t}};function ca(o={}){let t=new Pe;return o.fields&&t.fields(o.fields),o.steps&&t.steps(o.steps),o.initialData&&t.initialData(o.initialData),o.submitButton&&t.submitButton(o.submitButton),o.completedIndicator!==void 0&&t.completedIndicator(o.completedIndicator),o.direction&&t.direction(o.direction),o.persistence&&t.persistence(o.persistence.key,o.persistence),o.stepStyle&&t.stepStyle(o.stepStyle),o.completeTime&&t.withCompleteTime(o.completeTime),t.build()}export{U as AttemptsLock,P as ConditionEngine,qe as EasyForm,Pe as EasyFormBuilder,re as INJECTION_VALIDATION_MESSAGE,N as MaskEngine,gt as PREDEFINED_MASKS,O as SchemaParser,Z as StateManager,Y as ValidationEngine,H as attributeValue,bt as containsInjection,ca as createFormSchema,et as createInput,rt as extendTemplate,Wa as generateId,la as getAvailableTemplates,j as getColors,Ie as getCustomComponent,I as getNestedValue,Ve as getPredefinedMask,$e as getTemplate,te as getThemeStyles,W as isSafeFromInjection,yt as isValidEmail,q as parseAttributeValue,Ot as registerComponent,tt as registerComponents,Ua as sanitizeId,B as setNestedValue,Re as templates};
|
|
2551
2670
|
//# sourceMappingURL=index.js.map
|