@schema-forms-data/renderer 4.0.5 → 4.0.6

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/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var lr=Object.defineProperty;var dr=(t,e,r)=>e in t?lr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ke=(t,e,r)=>dr(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),x=require("react"),ke=require("@schema-forms-data/templates"),I=require("react-hook-form"),A=require("lucide-react"),F=require("@schema-forms-data/ui"),h=require("@schema-forms-data/core");function ur(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const Ue=ur(A),ze=x.createContext({}),xe=()=>x.useContext(ze),ut=new Set(["__proto__","constructor","prototype"]),Re=(t,e,r)=>{const s=e.split(".");let i=t;for(let o=0;o<s.length-1;o++){const c=s[o];if(ut.has(c))return;(i[c]==null||typeof i[c]!="object")&&(i[c]={}),i=i[c]}const a=s[s.length-1];ut.has(a)||(i[a]=r)},we=async(t,e,r,s,i,a)=>{for(const o of t){const c=a[o.type];if(!c)continue;const u=await c(r,s,o,i);if(u)return o.message??u}},Lt=(t,e={},r={})=>async s=>{var u,d,l,m,f;const i={},{errors:a}=h.validateStepData(t,s,e);for(const p of a){const g=p.campo.replace(/\[(\d+)\]/g,".$1");Re(i,g,{type:"custom",message:p.message})}const o=[...t.containers].sort((p,g)=>p.ordem-g.ordem);for(const p of o)if(!p.repeatable&&h.evaluateFieldCondition(p.condicional,s,e))for(const g of p.campos){if(g.tipo===h.FieldType.HIDDEN||g.isDisabled||g.isReadOnly||!h.evaluateFieldCondition(g.condicional,s,e))continue;if(g.tipo===h.FieldType.FIELD_ARRAY){const w=Array.isArray(s[g.nome])?s[g.nome]:[];for(let C=0;C<w.length;C++){const v=w[C];for(const y of g.subFields??[]){if(y.isDisabled||y.isReadOnly||!h.evaluateFieldCondition(y.condicional,v,e)||!((u=y.validate)!=null&&u.length)||i[`${g.nome}.${C}.${y.nome}`])continue;const D=await we(y.validate,y.nome,v[y.nome],v,e,r);D&&Re(i,`${g.nome}.${C}.${y.nome}`,{type:"custom",message:D})}}continue}if(g.tipo===h.FieldType.SUB_FORM){const w=s[g.nome]??{};for(const C of((d=g.subSchema)==null?void 0:d.fields)??[]){if(C.isDisabled||C.isReadOnly||!((l=C.validate)!=null&&l.length)||i[`${g.nome}.${C.nome}`])continue;const v=await we(C.validate,C.nome,w[C.nome],w,e,r);v&&Re(i,`${g.nome}.${C.nome}`,{type:"custom",message:v})}continue}if(!((m=g.validate)!=null&&m.length)||i[g.nome])continue;const k=await we(g.validate,g.nome,s[g.nome],s,e,r);k&&(i[g.nome]={type:"custom",message:k})}for(const p of o){if(!p.repeatable||!p.nome||!h.evaluateFieldCondition(p.condicional,s,e))continue;const g=Array.isArray(s[p.nome])?s[p.nome]:[];for(let k=0;k<g.length;k++){const w=g[k];for(const C of p.campos){if(C.tipo===h.FieldType.HIDDEN||C.isDisabled||C.isReadOnly||!h.evaluateFieldCondition(C.condicional,w,e)||!((f=C.validate)!=null&&f.length)||i[`${p.nome}.${k}.${C.nome}`])continue;const v=await we(C.validate,C.nome,w[C.nome],w,e,r);v&&Re(i,`${p.nome}.${k}.${C.nome}`,{type:"custom",message:v})}}}return Object.keys(i).length>0?{values:{},errors:i}:{values:s,errors:{}}},zt=(t,e={},r={})=>async s=>{var o,c;const i={},a=[...t.containers].sort((u,d)=>u.ordem-d.ordem);for(const u of a)if(!(u.condicional&&!h.evaluateFieldCondition(u.condicional,s,e))){if(u.repeatable&&u.nome){const d=Array.isArray(s[u.nome])?s[u.nome]:[];for(let l=0;l<d.length;l++){const m=d[l];for(const f of[...u.campos].sort((p,g)=>p.ordem-g.ordem)){if(!((o=f.warn)!=null&&o.length)||!h.evaluateFieldCondition(f.condicional,m,e))continue;const g=await we(f.warn,f.nome,m[f.nome],m,e,r);g&&(i[`${u.nome}.${l}.${f.nome}`]=g)}}continue}for(const d of[...u.campos].sort((l,m)=>l.ordem-m.ordem)){if(!((c=d.warn)!=null&&c.length)||!h.evaluateFieldCondition(d.condicional,s,e))continue;const m=await we(d.warn,d.nome,s[d.nome],s,e,r);m&&(i[d.nome]=m)}}return i},mr=/\{\{\s*(?:event|evento)\.([a-zA-Z0-9_.]+)\s*\}\}/g,K=(t,e)=>t?t.replace(mr,(r,s)=>e[`evento.${s}`]??e[s]??r):t??"",fr=(t,e)=>({...t,label:K(t.label,e)}),Mt=(t,e)=>{var r;return{...t,label:K(t.label,e),placeholder:K(t.placeholder,e),hint:K(t.hint,e),defaultValue:typeof t.defaultValue=="string"?K(t.defaultValue,e):t.defaultValue,opcoes:(r=t.opcoes)==null?void 0:r.map(s=>fr(s,e))}},Ve=(t,e)=>({...t,titulo:K(t.titulo,e),descricao:K(t.descricao,e),campos:t.campos.map(r=>Mt(r,e))}),$t=(t,e)=>({...t,titulo:K(t.titulo,e),descricao:K(t.descricao,e),containers:t.containers.map(r=>Ve(r,e))}),Ut=()=>{const t=ke.useTemplate(),e=t.layout.containerStyle,r=t.layout.roundness??"rounded-xl",s=F.cn("overflow-hidden",r,e==="card"?"border":"",e==="bordered"?"border":"",e==="glassmorphism"?"backdrop-blur-sm":""),i=e==="glassmorphism"?{background:"var(--t-surface)",borderColor:"var(--t-border)",borderWidth:"1px",borderStyle:"solid"}:{},a=F.cn("border-b px-6 py-4",e==="flat"?"border-transparent":"");return{wrapperClass:s,wrapperStyle:i,headerClass:a,headerStyle:e==="glassmorphism"?{borderColor:"var(--t-border)"}:{},tmpl:t}},re=({name:t,control:e,placeholder:r,type:s="text",disabled:i,readOnly:a})=>{var d;const{field:o,fieldState:c}=I.useController({name:t,control:e}),u=!!c.error;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(F.Input,{...o,value:o.value??"",type:s,placeholder:r,disabled:i,readOnly:a,className:F.cn(u&&"border-destructive focus-visible:ring-destructive")}),((d=c.error)==null?void 0:d.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},_e=({name:t,control:e,placeholder:r,disabled:s,readOnly:i})=>{var c;const{field:a,fieldState:o}=I.useController({name:t,control:e});return n.jsxs("div",{className:"space-y-1",children:[n.jsx(F.Textarea,{...a,value:a.value??"",placeholder:r,disabled:s,readOnly:i,rows:3,className:F.cn(o.error&&"border-destructive focus-visible:ring-destructive")}),((c=o.error)==null?void 0:c.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},We=({name:t,control:e,placeholder:r,options:s,disabled:i,readOnly:a})=>{var u;const{field:o,fieldState:c}=I.useController({name:t,control:e});return n.jsxs("div",{className:"space-y-1",children:[n.jsxs(F.Select,{value:o.value??"",onValueChange:d=>!a&&o.onChange(d),disabled:i||a,children:[n.jsx(F.SelectTrigger,{className:F.cn(c.error&&"border-destructive focus:ring-destructive"),onBlur:o.onBlur,children:n.jsx(F.SelectValue,{placeholder:r??"Selecione..."})}),n.jsx(F.SelectContent,{children:s.map(d=>n.jsx(F.SelectItem,{value:d.valor,disabled:d.disabled,children:d.label},d.valor))})]}),((u=c.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},qe=({name:t,control:e,label:r,disabled:s,readOnly:i})=>{var c;const{field:a,fieldState:o}=I.useController({name:t,control:e});return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx(F.Checkbox,{name:a.name,checked:!!a.value,onCheckedChange:u=>!i&&a.onChange(!!u),onBlur:a.onBlur,disabled:s}),r&&n.jsx("span",{className:"text-sm leading-none",children:r})]}),((c=o.error)==null?void 0:c.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},rt=({name:t,control:e,options:r,disabled:s})=>{var u;const{field:i,fieldState:a}=I.useController({name:t,control:e}),o=Array.isArray(i.value)?i.value:[],c=d=>{const l=o.includes(d)?o.filter(m=>m!==d):[...o,d];i.onChange(l)};return n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"flex flex-col gap-2",onBlur:i.onBlur,children:r.map(d=>n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx(F.Checkbox,{checked:o.includes(d.valor),onCheckedChange:()=>c(d.valor),disabled:s||d.disabled}),n.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((u=a.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:a.error.message})]})},st=({name:t,control:e,options:r,visualStyle:s="default",disabled:i})=>{var u;const{field:a,fieldState:o}=I.useController({name:t,control:e}),c=s==="card";return n.jsxs("div",{className:"space-y-1",onBlur:a.onBlur,children:[n.jsx(F.RadioGroup,{value:a.value??"",onValueChange:a.onChange,className:F.cn(c?"grid grid-cols-2 gap-2 sm:grid-cols-3":"flex flex-col gap-2"),children:r.map(d=>n.jsxs("label",{className:F.cn("flex items-center gap-2 cursor-pointer",c&&"rounded-lg border p-3 transition-colors hover:bg-accent data-[selected=true]:border-primary data-[selected=true]:bg-primary/5",(i||d.disabled)&&"cursor-not-allowed opacity-50"),"data-selected":a.value===d.valor?"true":void 0,children:[n.jsx(F.RadioGroupItem,{value:d.valor,disabled:i||d.disabled}),n.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((u=o.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},Vt=t=>{const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${s}`},xr=t=>{const e=new Date;return e.setFullYear(e.getFullYear()-t),Vt(e)},pr=t=>{const e=new Date;return e.setFullYear(e.getFullYear()-t),Vt(e)},je=({name:t,control:e,isDatetime:r,disabled:s,readOnly:i,validacao:a})=>{var f;const{field:o,fieldState:c}=I.useController({name:t,control:e}),u=r?"datetime-local":"date",d=p=>r?p+"T00:00":p,l=(a==null?void 0:a.minAge)!=null?d(xr(a.minAge)):(a==null?void 0:a.maxDate)!=null?d(a.maxDate):void 0,m=(a==null?void 0:a.maxAge)!=null?d(pr(a.maxAge)):(a==null?void 0:a.minDate)!=null?d(a.minDate):void 0;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(F.Input,{name:o.name,value:o.value??"",onChange:o.onChange,onBlur:o.onBlur,type:u,min:m,max:l,disabled:s,readOnly:i,className:F.cn(c.error&&"border-destructive focus-visible:ring-destructive")}),((f=c.error)==null?void 0:f.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})};function hr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const _t={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};for(const[t,e]of Object.entries(_t));let Oe;function gr(){if(!(typeof globalThis.TextDecoder>"u"))return Oe??(Oe=new globalThis.TextDecoder("utf-8"))}const Fe=32*1024,oe=65533;function br(t,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{const r=gr();return r?r.decode(t):vr(t)}case"utf-16le":return wr(t);case"us-ascii":case"ascii":return Cr(t);case"latin1":case"iso-8859-1":return jr(t);case"windows-1252":return Fr(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function nt(t,e){e.length!==0&&(t.push(String.fromCharCode.apply(null,e)),e.length=0)}function U(t,e,r){e.push(r),e.length>=Fe&&nt(t,e)}function yr(t,e,r){if(r<=65535){U(t,e,r);return}r-=65536,U(t,e,55296+(r>>10)),U(t,e,56320+(r&1023))}function vr(t){const e=[],r=[];let s=0;for(t.length>=3&&t[0]===239&&t[1]===187&&t[2]===191&&(s=3);s<t.length;){const i=t[s];if(i<=127){U(e,r,i),s++;continue}if(i<194||i>244){U(e,r,oe),s++;continue}if(i<=223){if(s+1>=t.length){U(e,r,oe),s++;continue}const l=t[s+1];if((l&192)!==128){U(e,r,oe),s++;continue}const m=(i&31)<<6|l&63;U(e,r,m),s+=2;continue}if(i<=239){if(s+2>=t.length){U(e,r,oe),s++;continue}const l=t[s+1],m=t[s+2];if(!((l&192)===128&&(m&192)===128&&!(i===224&&l<160)&&!(i===237&&l>=160))){U(e,r,oe),s++;continue}const p=(i&15)<<12|(l&63)<<6|m&63;U(e,r,p),s+=3;continue}if(s+3>=t.length){U(e,r,oe),s++;continue}const a=t[s+1],o=t[s+2],c=t[s+3];if(!((a&192)===128&&(o&192)===128&&(c&192)===128&&!(i===240&&a<144)&&!(i===244&&a>143))){U(e,r,oe),s++;continue}const d=(i&7)<<18|(a&63)<<12|(o&63)<<6|c&63;yr(e,r,d),s+=4}return nt(e,r),e.join("")}function wr(t){const e=[],r=[],s=t.length;let i=0;for(;i+1<s;){const a=t[i]|t[i+1]<<8;if(i+=2,a>=55296&&a<=56319){if(i+1<s){const o=t[i]|t[i+1]<<8;o>=56320&&o<=57343?(U(e,r,a),U(e,r,o),i+=2):U(e,r,oe)}else U(e,r,oe);continue}if(a>=56320&&a<=57343){U(e,r,oe);continue}U(e,r,a)}return i<s&&U(e,r,oe),nt(e,r),e.join("")}function Cr(t){const e=[];for(let r=0;r<t.length;r+=Fe){const s=Math.min(t.length,r+Fe),i=new Array(s-r);for(let a=r,o=0;a<s;a++,o++)i[o]=t[a]&127;e.push(String.fromCharCode.apply(null,i))}return e.join("")}function jr(t){const e=[];for(let r=0;r<t.length;r+=Fe){const s=Math.min(t.length,r+Fe),i=new Array(s-r);for(let a=r,o=0;a<s;a++,o++)i[o]=t[a];e.push(String.fromCharCode.apply(null,i))}return e.join("")}function Fr(t){const e=[];let r="";for(let s=0;s<t.length;s++){const i=t[s],a=i>=128&&i<=159?_t[i]:void 0;r+=a??String.fromCharCode(i),r.length>=Fe&&(e.push(r),r="")}return r&&e.push(r),e.join("")}function Q(t){return new DataView(t.buffer,t.byteOffset)}const kr={len:1,get(t,e){return Q(t).getUint8(e)},put(t,e,r){return Q(t).setUint8(e,r),e+1}},M={len:2,get(t,e){return Q(t).getUint16(e,!0)},put(t,e,r){return Q(t).setUint16(e,r,!0),e+2}},ve={len:2,get(t,e){return Q(t).getUint16(e)},put(t,e,r){return Q(t).setUint16(e,r),e+2}},$={len:4,get(t,e){return Q(t).getUint32(e,!0)},put(t,e,r){return Q(t).setUint32(e,r,!0),e+4}},mt={len:4,get(t,e){return Q(t).getUint32(e)},put(t,e,r){return Q(t).setUint32(e,r),e+4}},Nr={len:4,get(t,e){return Q(t).getInt32(e)},put(t,e,r){return Q(t).setInt32(e,r),e+4}},Sr={len:8,get(t,e){return Q(t).getBigUint64(e,!0)},put(t,e,r){return Q(t).setBigUint64(e,r,!0),e+8}};class fe{constructor(e,r){this.len=e,this.encoding=r}get(e,r=0){const s=e.subarray(r,r+this.len);return br(s,this.encoding)}}const Dr="End-Of-Stream";class V extends Error{constructor(){super(Dr),this.name="EndOfStreamError"}}class Tr extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}class Wt{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,r=!1){const s=await this.read(e,r);return this.peekQueue.push(e.subarray(0,s)),s}async read(e,r=!1){if(e.length===0)return 0;let s=this.readFromPeekBuffer(e);if(this.endOfStream||(s+=await this.readRemainderFromStream(e.subarray(s),r)),s===0&&!r)throw new V;return s}readFromPeekBuffer(e){let r=e.length,s=0;for(;this.peekQueue.length>0&&r>0;){const i=this.peekQueue.pop();if(!i)throw new Error("peekData should be defined");const a=Math.min(i.length,r);e.set(i.subarray(0,a),s),s+=a,r-=a,a<i.length&&this.peekQueue.push(i.subarray(a))}return s}async readRemainderFromStream(e,r){let s=0;for(;s<e.length&&!this.endOfStream;){if(this.interrupted)throw new Tr;const i=await this.readFromStream(e.subarray(s),r);if(i===0)break;s+=i}if(!r&&s<e.length)throw new V;return s}}class Er extends Wt{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class Ar extends Er{async readFromStream(e,r){if(e.length===0)return 0;const s=await this.reader.read(new Uint8Array(e.length),{min:r?void 0:e.length});return s.done&&(this.endOfStream=s.done),s.value?(e.set(s.value),s.value.length):0}}class ft extends Wt{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,r){const s=Math.min(r.length,e.length);return e.set(r.subarray(0,s)),s<r.length?this.buffer=r.subarray(s):this.buffer=null,s}async readFromStream(e,r){if(e.length===0)return 0;let s=0;for(this.buffer&&(s+=this.writeChunk(e,this.buffer));s<e.length&&!this.endOfStream;){const i=await this.reader.read();if(i.done){this.endOfStream=!0;break}i.value&&(s+=this.writeChunk(e.subarray(s),i.value))}if(!r&&s===0&&this.endOfStream)throw new V;return s}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}function Ir(t){try{const e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new ft(e):new Ar(e)}catch(e){if(e instanceof TypeError)return new ft(t.getReader());throw e}}class it{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e==null?void 0:e.onClose,e!=null&&e.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,r=this.position){const s=new Uint8Array(e.len);if(await this.readBuffer(s,{position:r})<e.len)throw new V;return e.get(s,0)}async peekToken(e,r=this.position){const s=new Uint8Array(e.len);if(await this.peekBuffer(s,{position:r})<e.len)throw new V;return e.get(s,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new V;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new V;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw new RangeError("ignore length must be ≥ 0 bytes");if(this.fileInfo.size!==void 0){const r=this.fileInfo.size-this.position;if(e>r)return this.position+=r,r}return this.position+=e,e}async close(){var e;await this.abort(),await((e=this.onClose)==null?void 0:e.call(this))}normalizeOptions(e,r){if(!this.supportsRandomAccess()&&r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...r}}abort(){return Promise.resolve()}}const Br=256e3;class Rr extends it{constructor(e,r){super(r),this.streamReader=e,this.fileInfo=(r==null?void 0:r.fileInfo)??{}}async readBuffer(e,r){const s=this.normalizeOptions(e,r),i=s.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(e,r);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(s.length===0)return 0;const a=await this.streamReader.read(e.subarray(0,s.length),s.mayBeLess);if(this.position+=a,(!r||!r.mayBeLess)&&a<s.length)throw new V;return a}async peekBuffer(e,r){const s=this.normalizeOptions(e,r);let i=0;if(s.position){const a=s.position-this.position;if(a>0){const o=new Uint8Array(s.length+a);return i=await this.peekBuffer(o,{mayBeLess:s.mayBeLess}),e.set(o.subarray(a)),i-a}if(a<0)throw new Error("Cannot peek from a negative offset in a stream")}if(s.length>0){try{i=await this.streamReader.peek(e.subarray(0,s.length),s.mayBeLess)}catch(a){if(r!=null&&r.mayBeLess&&a instanceof V)return 0;throw a}if(!s.mayBeLess&&i<s.length)throw new V}return i}async ignore(e){if(e<0)throw new RangeError("ignore length must be ≥ 0 bytes");const r=Math.min(Br,e),s=new Uint8Array(r);let i=0;for(;i<e;){const a=e-i,o=await this.readBuffer(s,{length:Math.min(r,a)});if(o<0)return o;i+=o}return i}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class Or extends it{constructor(e,r){super(r),this.uint8Array=e,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:e.length}}async readBuffer(e,r){r!=null&&r.position&&(this.position=r.position);const s=await this.peekBuffer(e,r);return this.position+=s,s}async peekBuffer(e,r){const s=this.normalizeOptions(e,r),i=Math.min(this.uint8Array.length-s.position,s.length);if(!s.mayBeLess&&i<s.length)throw new V;return e.set(this.uint8Array.subarray(s.position,s.position+i)),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}class Pr extends it{constructor(e,r){super(r),this.blob=e,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:e.size,mimeType:e.type}}async readBuffer(e,r){r!=null&&r.position&&(this.position=r.position);const s=await this.peekBuffer(e,r);return this.position+=s,s}async peekBuffer(e,r){const s=this.normalizeOptions(e,r),i=Math.min(this.blob.size-s.position,s.length);if(!s.mayBeLess&&i<s.length)throw new V;const a=await this.blob.slice(s.position,s.position+i).arrayBuffer();return e.set(new Uint8Array(a)),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}function Lr(t,e){const r=Ir(t),s=e??{},i=s.onClose;return s.onClose=async()=>{if(await r.close(),i)return i()},new Rr(r,s)}function zr(t,e){return new Or(t,e)}function Mr(t,e){return new Pr(t,e)}var tt={exports:{}},Xe,xt;function $r(){if(xt)return Xe;xt=1;var t=1e3,e=t*60,r=e*60,s=r*24,i=s*7,a=s*365.25;Xe=function(l,m){m=m||{};var f=typeof l;if(f==="string"&&l.length>0)return o(l);if(f==="number"&&isFinite(l))return m.long?u(l):c(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function o(l){if(l=String(l),!(l.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(m){var f=parseFloat(m[1]),p=(m[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return f*a;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*s;case"hours":case"hour":case"hrs":case"hr":case"h":return f*r;case"minutes":case"minute":case"mins":case"min":case"m":return f*e;case"seconds":case"second":case"secs":case"sec":case"s":return f*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function c(l){var m=Math.abs(l);return m>=s?Math.round(l/s)+"d":m>=r?Math.round(l/r)+"h":m>=e?Math.round(l/e)+"m":m>=t?Math.round(l/t)+"s":l+"ms"}function u(l){var m=Math.abs(l);return m>=s?d(l,m,s,"day"):m>=r?d(l,m,r,"hour"):m>=e?d(l,m,e,"minute"):m>=t?d(l,m,t,"second"):l+" ms"}function d(l,m,f,p){var g=m>=f*1.5;return Math.round(l/f)+" "+p+(g?"s":"")}return Xe}function Ur(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=i,r.enabled=c,r.humanize=$r(),r.destroy=d,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function e(l){let m=0;for(let f=0;f<l.length;f++)m=(m<<5)-m+l.charCodeAt(f),m|=0;return r.colors[Math.abs(m)%r.colors.length]}r.selectColor=e;function r(l){let m,f=null,p,g;function k(...w){if(!k.enabled)return;const C=k,v=Number(new Date),y=v-(m||v);C.diff=y,C.prev=m,C.curr=v,m=v,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let D=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(E,j)=>{if(E==="%%")return"%";D++;const b=r.formatters[j];if(typeof b=="function"){const S=w[D];E=b.call(C,S),w.splice(D,1),D--}return E}),r.formatArgs.call(C,w),(C.log||r.log).apply(C,w)}return k.namespace=l,k.useColors=r.useColors(),k.color=r.selectColor(l),k.extend=s,k.destroy=r.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(p!==r.namespaces&&(p=r.namespaces,g=r.enabled(l)),g),set:w=>{f=w}}),typeof r.init=="function"&&r.init(k),k}function s(l,m){const f=r(this.namespace+(typeof m>"u"?":":m)+l);return f.log=this.log,f}function i(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];const m=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const f of m)f[0]==="-"?r.skips.push(f.slice(1)):r.names.push(f)}function a(l,m){let f=0,p=0,g=-1,k=0;for(;f<l.length;)if(p<m.length&&(m[p]===l[f]||m[p]==="*"))m[p]==="*"?(g=p,k=f,p++):(f++,p++);else if(g!==-1)p=g+1,k++,f=k;else return!1;for(;p<m.length&&m[p]==="*";)p++;return p===m.length}function o(){const l=[...r.names,...r.skips.map(m=>"-"+m)].join(",");return r.enable(""),l}function c(l){for(const m of r.skips)if(a(l,m))return!1;for(const m of r.names)if(a(l,m))return!0;return!1}function u(l){return l instanceof Error?l.stack||l.message:l}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var Vr=Ur;(function(t,e){e.formatArgs=s,e.save=i,e.load=a,e.useColors=r,e.storage=o(),e.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function s(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;u.splice(1,0,d,"color: inherit");let l=0,m=0;u[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(l++,f==="%c"&&(m=l))}),u.splice(m,0,d)}e.log=console.debug||console.log||(()=>{});function i(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch{}}function a(){let u;try{u=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!u&&typeof process<"u"&&"env"in process&&(u=process.env.DEBUG),u}function o(){try{return localStorage}catch{}}t.exports=Vr(e);const{formatters:c}=t.exports;c.j=function(u){try{return JSON.stringify(u)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(tt,tt.exports);var _r=tt.exports;const Wr=hr(_r),Ce={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},pt={get(t){return{signature:$.get(t,0),compressedSize:$.get(t,8),uncompressedSize:$.get(t,12)}},len:16},qr={get(t){const e=M.get(t,6);return{signature:$.get(t,0),minVersion:M.get(t,4),dataDescriptor:!!(e&8),compressedMethod:M.get(t,8),compressedSize:$.get(t,18),uncompressedSize:$.get(t,22),filenameLength:M.get(t,26),extraFieldLength:M.get(t,28),filename:null}},len:30},Zr={get(t){return{signature:$.get(t,0),nrOfThisDisk:M.get(t,4),nrOfThisDiskWithTheStart:M.get(t,6),nrOfEntriesOnThisDisk:M.get(t,8),nrOfEntriesOfSize:M.get(t,10),sizeOfCd:$.get(t,12),offsetOfStartOfCd:$.get(t,16),zipFileCommentLength:M.get(t,20)}},len:22},Hr={get(t){const e=M.get(t,8);return{signature:$.get(t,0),minVersion:M.get(t,6),dataDescriptor:!!(e&8),compressedMethod:M.get(t,10),compressedSize:$.get(t,20),uncompressedSize:$.get(t,24),filenameLength:M.get(t,28),extraFieldLength:M.get(t,30),fileCommentLength:M.get(t,32),relativeOffsetOfLocalHeader:$.get(t,42),filename:null}},len:46};function qt(t){const e=new Uint8Array($.len);return $.put(e,0,t),e}const ce=Wr("tokenizer:inflate"),Ye=256*1024,Gr=qt(Ce.DataDescriptor),Pe=qt(Ce.EndOfCentralDirectory);class De{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Ye)}async isZip(){return await this.peekSignature()===Ce.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken($)}async findEndOfCentralDirectoryLocator(){const e=this.tokenizer,r=Math.min(16*1024,e.fileInfo.size),s=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(s,{position:e.fileInfo.size-r});for(let i=s.length-4;i>=0;i--)if(s[i]===Pe[0]&&s[i+1]===Pe[1]&&s[i+2]===Pe[2]&&s[i+3]===Pe[3])return e.fileInfo.size-r+i;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){ce("Cannot reading central-directory without random-read support");return}ce("Reading central-directory...");const e=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){ce("Central-directory 32-bit signature found");const s=await this.tokenizer.readToken(Zr,r),i=[];this.tokenizer.setPosition(s.offsetOfStartOfCd);for(let a=0;a<s.nrOfEntriesOfSize;++a){const o=await this.tokenizer.readToken(Hr);if(o.signature!==Ce.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new fe(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),i.push(o),ce(`Add central-directory file-entry: n=${a+1}/${i.length}: filename=${i[a].filename}`)}return this.tokenizer.setPosition(e),i}this.tokenizer.setPosition(e)}async unzip(e){const r=await this.readCentralDirectory();if(r)return this.iterateOverCentralDirectory(r,e);let s=!1;do{const i=await this.readLocalFileHeader();if(!i)break;const a=e(i);s=!!a.stop;let o;if(await this.tokenizer.ignore(i.extraFieldLength),i.dataDescriptor&&i.compressedSize===0){const c=[];let u=Ye;ce("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let d=-1;for(;d<0&&u===Ye;){u=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),d=Kr(this.syncBuffer.subarray(0,u),Gr);const l=d>=0?d:u;if(a.handler){const m=new Uint8Array(l);await this.tokenizer.readBuffer(m),c.push(m)}else await this.tokenizer.ignore(l)}ce(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),a.handler&&await this.inflate(i,Xr(c),a.handler)}else a.handler?(ce(`Reading compressed-file-data: ${i.compressedSize} bytes`),o=new Uint8Array(i.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(i,o,a.handler)):(ce(`Ignoring compressed-file-data: ${i.compressedSize} bytes`),await this.tokenizer.ignore(i.compressedSize));if(ce(`Reading data-descriptor at pos=${this.tokenizer.position}`),i.dataDescriptor&&(await this.tokenizer.readToken(pt)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-pt.len}`)}while(!s)}async iterateOverCentralDirectory(e,r){for(const s of e){const i=r(s);if(i.handler){this.tokenizer.setPosition(s.relativeOffsetOfLocalHeader);const a=await this.readLocalFileHeader();if(a){await this.tokenizer.ignore(a.extraFieldLength);const o=new Uint8Array(s.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(a,o,i.handler)}}if(i.stop)break}}async inflate(e,r,s){if(e.compressedMethod===0)return s(r);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);ce(`Decompress filename=${e.filename}, compressed-size=${r.length}`);const i=await De.decompressDeflateRaw(r);return s(i)}static async decompressDeflateRaw(e){const r=new ReadableStream({start(a){a.enqueue(e),a.close()}}),s=new DecompressionStream("deflate-raw"),i=r.pipeThrough(s);try{const o=await new Response(i).arrayBuffer();return new Uint8Array(o)}catch(a){const o=a instanceof Error?`Failed to deflate ZIP entry: ${a.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){const e=await this.tokenizer.peekToken($);if(e===Ce.LocalFileHeader){const r=await this.tokenizer.readToken(qr);return r.filename=await this.tokenizer.readToken(new fe(r.filenameLength,"utf-8")),r}if(e===Ce.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}function Kr(t,e){const r=t.length,s=e.length;if(s>r)return-1;for(let i=0;i<=r-s;i++){let a=!0;for(let o=0;o<s;o++)if(t[i+o]!==e[o]){a=!1;break}if(a)return i}return-1}function Xr(t){const e=t.reduce((i,a)=>i+a.length,0),r=new Uint8Array(e);let s=0;for(const i of t)r.set(i,s),s+=i.length;return r}class Yr{constructor(e){this.tokenizer=e}inflate(){const e=this.tokenizer;return new ReadableStream({async pull(r){const s=new Uint8Array(1024),i=await e.readBuffer(s,{mayBeLess:!0});if(i===0){r.close();return}r.enqueue(s.subarray(0,i))}}).pipeThrough(new DecompressionStream("gzip"))}}new globalThis.TextDecoder("utf8");new globalThis.TextEncoder;Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ht(t){const{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}function Jr(t,e){if(e==="utf-16le"){const r=[];for(let s=0;s<t.length;s++){const i=t.charCodeAt(s);r.push(i&255,i>>8&255)}return r}if(e==="utf-16be"){const r=[];for(let s=0;s<t.length;s++){const i=t.charCodeAt(s);r.push(i>>8&255,i&255)}return r}return[...t].map(r=>r.charCodeAt(0))}function Qr(t,e=0){const r=Number.parseInt(new fe(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let s=8*32;for(let i=e;i<e+148;i++)s+=t[i];for(let i=e+156;i<e+512;i++)s+=t[i];return r===s}const es={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4},ts=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],rs=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"],Ne=4100,ss=Ne-2,de=1024*1024,gt=1024,ns=2**31-1,ie=16*1024*1024,Ze=de,bt=de,is=ie,as=1,yt=100,Je=ie,vt=64,wt=Ze,os=256,cs=512,ls=ie,ds=512,us=512,Ct=256,jt=Ze,Ft=Ze,ms=Ze,kt=ie,fs=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),xs=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],ps=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);class ye extends Error{}function hs(t){var i;const e=t==null?void 0:t.streamReader;if(((i=e==null?void 0:e.constructor)==null?void 0:i.name)!=="WebStreamByobReader")return t;const{reader:r}=e,s=async()=>{await r.cancel(),r.releaseLock()};return e.close=s,e.abort=async()=>{e.interrupted=!0,await s()},t}function at(t,e,r){if(!Number.isFinite(t)||t<0||t>e)throw new ye(`${r} has invalid size ${t} (maximum ${e} bytes)`);return t}async function he(t,e,{maximumLength:r=ie,reason:s="skip"}={}){const i=at(e,r,s);await t.ignore(i)}async function Qe(t,e,r,{maximumLength:s=e.length,reason:i="read"}={}){const a=e.length,o=at(a,s,i);return t.readBuffer(e,{...r,length:o})}async function gs(t,{maximumLength:e=de}={}){const i=new ReadableStream({start(d){d.enqueue(t),d.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),a=[];let o=0;try{for(;;){const{done:d,value:l}=await i.read();if(d)break;if(o+=l.length,o>e)throw await i.cancel(),new Error(`ZIP entry decompressed data exceeds ${e} bytes`);a.push(l)}}finally{i.releaseLock()}const c=new Uint8Array(o);let u=0;for(const d of a)c.set(d,u),u+=d.length;return c}const Zt=134695760,Me=16,bs=Me-1;function ys(t,e){if(t.length<Me)return-1;const r=t.length-Me;for(let s=0;s<=r;s++)if($.get(t,s)===Zt&&$.get(t,s+8)===e+s)return s;return-1}function vs(t){return(t.codePointAt(0)&32)!==0}function ws(t,e){const r=new Uint8Array(e);let s=0;for(const i of t)r.set(i,s),s+=i.length;return r}async function Cs(t,{shouldBuffer:e,maximumLength:r=de}={}){const{syncBuffer:s}=t,{length:i}=s,a=[];let o=0;for(;;){const c=await t.tokenizer.peekBuffer(s,{mayBeLess:!0}),u=ys(s.subarray(0,c),o),d=u>=0?0:c===i?Math.min(bs,c-1):0,l=u>=0?u:c-d;if(l===0)break;if(o+=l,o>r)throw new Error(`ZIP entry compressed data exceeds ${r} bytes`);if(e){const m=new Uint8Array(l);await t.tokenizer.readBuffer(m),a.push(m)}else await t.tokenizer.ignore(l);if(u>=0)break}if(G(t.tokenizer)||(t.knownSizeDescriptorScannedBytes+=o),!!e)return ws(a,o)}function js(t,e){return G(t.tokenizer)?Math.max(0,ie-(t.tokenizer.position-e)):Math.max(0,de-t.knownSizeDescriptorScannedBytes)}async function Fs(t,e,{shouldBuffer:r,maximumDescriptorLength:s=de}={}){if(e.dataDescriptor&&e.compressedSize===0)return Cs(t,{shouldBuffer:r,maximumLength:s});if(!r){await he(t.tokenizer,e.compressedSize,{maximumLength:G(t.tokenizer)?de:t.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}const i=As(t.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>i)throw new Error(`ZIP entry compressed data exceeds ${i} bytes`);const a=new Uint8Array(e.compressedSize);return await t.tokenizer.readBuffer(a),a}De.prototype.inflate=async function(t,e,r){if(t.compressedMethod===0)return r(e);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);const s=await gs(e,{maximumLength:de});return r(s)};De.prototype.unzip=async function(t){let e=!1,r=0;const s=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(Se(this.tokenizer,s,ie))throw new ye(`ZIP stream probing exceeds ${ie} bytes`);const i=await this.readLocalFileHeader();if(!i)break;if(r++,r>gt)throw new Error(`ZIP entry count exceeds ${gt}`);const a=t(i);e=!!a.stop,await this.tokenizer.ignore(i.extraFieldLength);const o=await Fs(this,i,{shouldBuffer:!!a.handler,maximumDescriptorLength:Math.min(de,js(this,s))});if(a.handler&&await this.inflate(i,o,a.handler),i.dataDescriptor){const c=new Uint8Array(Me);if(await this.tokenizer.readBuffer(c),$.get(c,0)!==Zt)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-c.length}`)}if(Se(this.tokenizer,s,ie))throw new ye(`ZIP stream probing exceeds ${ie} bytes`)}while(!e)};function ks(t,e){const r=t.getReader();let s=0,i=!1,a=!1;const o=async c=>{i||a||(a=!0,await r.cancel(c))};return new ReadableStream({async pull(c){if(s>=e){c.close(),await o();return}const{done:u,value:d}=await r.read();if(u||!d){i=!0,c.close();return}const l=e-s;if(d.length>l){c.enqueue(d.subarray(0,l)),s+=l,c.close(),await o();return}c.enqueue(d),s+=d.length},async cancel(c){await o(c)}})}async function Ns(t,e){return new ot(e).fromBlob(t)}function Nt(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function le(t,e,r){r={offset:0,...r};for(const[s,i]of e.entries())if(r.mask){if(i!==(r.mask[s]&t[s+r.offset]))return!1}else if(i!==t[s+r.offset])return!1;return!0}function Ss(t){return Number.isFinite(t)?Math.max(1,Math.trunc(t)):Ne}function Ds(t,e,r){return r===void 0?t.read(e):(r.throwIfAborted(),new Promise((s,i)=>{const a=()=>{r.removeEventListener("abort",o)},o=()=>{const c=r.reason;a(),(async()=>{try{await t.cancel(c)}catch{}})(),i(c)};r.addEventListener("abort",o,{once:!0}),(async()=>{try{const c=await t.read(e);a(),s(c)}catch(c){a(),i(c)}})()}))}function Ts(t){return Number.isFinite(t)?Math.max(0,Math.min(ss,Math.trunc(t))):0}function Es(t){return Number.isFinite(t)?Math.max(0,t):Number.MAX_SAFE_INTEGER}function G(t){const e=t.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function Se(t,e,r){return G(t)&&t.position-e>r}function As(t){const e=t.fileInfo.size,r=Number.isFinite(e)?Math.max(0,e-t.position):Number.MAX_SAFE_INTEGER;return Math.min(r,ns)}function Is(t){if(t instanceof V||t instanceof ye)return!0;if(!(t instanceof Error))return!1;if(fs.has(t.message)||ps.has(t.code))return!0;for(const e of xs)if(t.message.startsWith(e))return!0;return!1}function St(t,e=de){const r=[t.compressedSize,t.uncompressedSize];for(const s of r)if(!Number.isFinite(s)||s<0||s>e)return!1;return!0}function Bs(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function Rs(t,e){e.startsWith("word/")&&(t.hasWordDirectory=!0),e.startsWith("ppt/")&&(t.hasPresentationDirectory=!0),e.startsWith("xl/")&&(t.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(t.hasThreeDimensionalModelEntry=!0)}function Dt(t){if(!(!t.hasContentTypesEntry||t.hasUnparseableContentTypes||t.isParsingContentTypes||t.hasParsedContentTypesEntry)){if(t.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(t.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(t.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(t.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function Os(t){const e=t.indexOf('.main+xml"');if(e===-1){const i="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return t.includes(`ContentType="${i}"`)?i:void 0}const r=t.slice(0,e),s=r.lastIndexOf('"');return r.slice(s+1)}class ot{constructor(e){Ke(this,"detectConfident",async e=>{if(this.buffer=new Uint8Array(Ne),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,G(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=Ct?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await he(e,6,{maximumLength:6,reason:"ID3 header prefix"});const r=await e.readToken(es),s=G(e);if(!Number.isFinite(r)||r<0||s&&(r>Je||e.position+r>Je))return;if(e.position+r>e.fileInfo.size)return s?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await he(e,r,{maximumLength:s?Je:e.fileInfo.size,reason:"ID3 payload"})}catch(i){if(i instanceof V)return;throw i}return this.detectionReentryCount>=Ct?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let r;const s=Bs();try{await new De(e).unzip(i=>{Rs(s,i.filename);const a=i.filename==="[Content_Types].xml",o=Dt(s);if(!a&&o)return r=o,{stop:!0};switch(i.filename){case"META-INF/mozilla.rsa":return r={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return r={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return St(i,bt)?{async handler(c){const u=new TextDecoder("utf-8").decode(c).trim();r=Nt(u)},stop:!0}:{};case"[Content_Types].xml":return s.hasContentTypesEntry=!0,St(i,bt)?(s.isParsingContentTypes=!0,{async handler(c){const u=new TextDecoder("utf-8").decode(c),d=Os(u);d&&(r=Nt(d)),s.hasParsedContentTypesEntry=!0,s.isParsingContentTypes=!1},stop:!0}):(s.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(i.filename)?(r={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(i){if(!Is(i))throw i;s.isParsingContentTypes&&(s.isParsingContentTypes=!1,s.hasUnparseableContentTypes=!0)}return r??Dt(s)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);const r=new Uint8Array(8);return await e.readBuffer(r),le(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:le(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:le(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:le(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:le(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:le(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){const r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){const u=await e.peekNumber(kr);let d=128,l=0;for(;!(u&d)&&d!==0;)++l,d>>=1;const m=new Uint8Array(l+1);return await Qe(e,m,void 0,{maximumLength:m.length,reason:"EBML field"}),m}async function s(){const u=await r(),d=await r();d[0]^=128>>d.length-1;const l=Math.min(6,d.length),m=new DataView(u.buffer),f=new DataView(d.buffer,d.length-l,l);return{id:ht(m),len:ht(f)}}async function i(u){let d=0;for(;u>0;){if(d++,d>os||Se(e,o,ie))return;const l=e.position,m=await s();if(m.id===17026){if(m.len>vt)return;const f=at(m.len,vt,"EBML DocType");return(await e.readToken(new fe(f))).replaceAll(/\00.*$/g,"")}if(G(e)&&(!Number.isFinite(m.len)||m.len<0||m.len>wt)||(await he(e,m.len,{maximumLength:G(e)?wt:e.fileInfo.size,reason:"EBML payload"}),--u,e.position<=l))return}}const a=await s(),o=e.position;switch(await i(a.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const r=mt.get(this.buffer,4),s=ve.get(this.buffer,6);if(r>0&&r<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(s>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const r=new fe(4,"latin1").get(this.buffer,2);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new fe(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
2
- `,"\r"," "," ","\0"].some(r=>this.checkString(r,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){const r={ext:"png",mime:"image/png"},s={ext:"apng",mime:"image/apng"};await e.ignore(8);async function i(){return{length:await e.readToken(Nr),type:await e.readToken(new fe(4,"latin1"))}}const a=G(e),o=e.position;let c=0,u=!1;do{if(c++,c>cs||Se(e,o,ls))break;const d=e.position,l=await i();if(l.length<0)return;if(l.type==="IHDR"){if(l.length!==13)return;u=!0}switch(l.type){case"IDAT":return r;case"acTL":return s;default:if(!u&&l.type!=="CgBI")return;if(a&&l.length>jt)return u&&vs(l.type)?r:void 0;try{await he(e,l.length+4,{maximumLength:a?jt+4:e.fileInfo.size,reason:"PNG chunk payload"})}catch(m){if(!a&&(m instanceof ye||m instanceof V))return r;throw m}}if(e.position<=d)break}while(e.position+8<e.fileInfo.size);return r}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&this.buffer[8]&96){const r=new fe(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
3
- `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let r=!1;try{async function s(){const c=new Uint8Array(16);return await Qe(e,c,void 0,{maximumLength:c.length,reason:"ASF header GUID"}),{id:c,size:Number(await e.readToken(Sr))}}await he(e,30,{maximumLength:30,reason:"ASF header prelude"});const i=G(e),a=e.position;let o=0;for(;e.position+24<e.fileInfo.size&&(o++,!(o>ds||Se(e,a,ie)));){const c=e.position,u=await s();let d=u.size-24;if(!Number.isFinite(d)||d<0){r=!0;break}if(le(u.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const l=new Uint8Array(16);if(d-=await Qe(e,l,void 0,{maximumLength:l.length,reason:"ASF stream type GUID"}),le(l,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(le(l,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&d>Ft){r=!0;break}if(await he(e,d,{maximumLength:i?Ft:e.fileInfo.size,reason:"ASF header payload"}),e.position<=c){r=!0;break}}}catch(s){if(s instanceof V||s instanceof ye)G(e)&&(r=!0);else throw s}return r?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new fe(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const r=new DataView(this.buffer.buffer).getUint32(12,!0);if(r>12&&this.buffer.length>=r+16)try{const s=new TextDecoder().decode(this.buffer.subarray(16,r+16));if(JSON.parse(s).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Qr(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){const r="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:r})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:r})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
4
- `,{offset:2,encoding:r})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}});Ke(this,"detectImprecise",async e=>{this.buffer=new Uint8Array(Ne);const r=Es(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,r),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,r),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let s=0;s<=this.options.mpegOffsetTolerance;++s){const i=this.scanMpeg(s);if(i)return i}});const r=Ts(e==null?void 0:e.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:r},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return hs(Lr(e,this.getTokenizerOptions()))}async parseTokenizer(e,r=0){this.detectionReentryCount=r;const s=e.position;for(const i of this.detectors){let a;try{a=await i.detect(e)}catch(o){if(o instanceof V||o instanceof ye)return;throw o}if(a)return a;if(s!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);const r=e instanceof Uint8Array?e:new Uint8Array(e);if((r==null?void 0:r.length)>1)return this.fromTokenizer(zr(r,this.getTokenizerOptions()))}async fromBlob(e){var s;(s=this.options.signal)==null||s.throwIfAborted();const r=Mr(e,this.getTokenizerOptions());return this.fromTokenizer(r)}async fromStream(e){var s;(s=this.options.signal)==null||s.throwIfAborted();const r=this.createTokenizerFromWebStream(e);return this.fromTokenizer(r)}async toDetectionStream(e,r){const s=Ss((r==null?void 0:r.sampleSize)??Ne);let i,a;const o=e.getReader({mode:"byob"});try{const{value:d,done:l}=await Ds(o,new Uint8Array(s),this.options.signal);if(a=d,!l&&d)try{i=await this.fromBuffer(d.subarray(0,s))}catch(m){if(!(m instanceof V))throw m;i=void 0}a=d}finally{o.releaseLock()}const c=new TransformStream({async start(d){d.enqueue(a)},transform(d,l){l.enqueue(d)}}),u=e.pipeThrough(c);return u.fileType=i,u}async detectGzip(e){var d;if(this.gzipProbeDepth>=as)return{ext:"gz",mime:"application/gzip"};const r=new Yr(e),s=ks(r.inflate(),is),i=G(e);let a,o,c,u;if(i){const l=new AbortController;a=setTimeout(()=>{l.abort(new DOMException(`Operation timed out after ${yt} ms`,"TimeoutError"))},yt),o=this.options.signal===void 0?l.signal:AbortSignal.any([this.options.signal,l.signal]),c=new ot({...this.options,signal:o}),c.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{u=await(c??this).fromStream(s)}catch(l){if((l==null?void 0:l.name)==="AbortError"&&((d=o==null?void 0:o.reason)==null?void 0:d.name)!=="TimeoutError")throw l}finally{clearTimeout(a),i||this.gzipProbeDepth--}return(u==null?void 0:u.ext)==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,r){return le(this.buffer,e,r)}checkString(e,r){return this.check(Jr(e,r==null?void 0:r.encoding),r)}async readTiffTag(e){const r=await this.tokenizer.readToken(e?ve:M);switch(await this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const r=await this.tokenizer.readToken(e?ve:M);if(!(r>us)&&!(G(this.tokenizer)&&2+r*12>kt))for(let s=0;s<r;++s){const i=await this.readTiffTag(e);if(i)return i}}async readTiffHeader(e){const r={ext:"tif",mime:"image/tiff"},s=(e?ve:M).get(this.buffer,2),i=(e?mt:$).get(this.buffer,4);if(s===42){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){const c=(e?ve:M).get(this.buffer,8),u=(e?ve:M).get(this.buffer,10);if(c===28&&u===254||c===31&&u===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(G(this.tokenizer)&&i>ms)return r;const a=G(this.tokenizer)?kt:this.tokenizer.fileInfo.size;try{await he(this.tokenizer,i,{maximumLength:a,reason:"TIFF IFD offset"})}catch(c){if(c instanceof V)return;throw c}let o;try{o=await this.readTiffIFD(e)}catch(c){if(c instanceof V)return;throw c}return o??r}if(s===43)return r}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(ts);new Set(rs);const Tt=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,ct=({name:t,control:e,disabled:r,campo:s,fileTypes:i,maxFileSize:a})=>{var E;const{field:o,fieldState:c}=I.useController({name:t,control:e}),{uploadFile:u,deleteUploadedFile:d}=xe(),[l,m]=x.useState({status:"idle"}),f=x.useRef(null),[p,g]=x.useState(!1),k=x.useRef(!0);x.useEffect(()=>()=>{k.current=!1},[]);const w=typeof o.value=="string"&&o.value?o.value:null,C=x.useCallback(async j=>{var b;if(i&&i.length>0){const S=await Ns(j),N=(S==null?void 0:S.ext)??"",R=(S==null?void 0:S.mime)??"",W=((b=j.name.split(".").pop())==null?void 0:b.toLowerCase())??"",Z=j.type.toLowerCase();if(!i.some(te=>{const _=te.toLowerCase();return!!(N&&(_===N||_===R)||R&&_.endsWith("/*")&&R.startsWith(_.slice(0,-1))||!N&&(_===W||_===Z||_.endsWith("/*")&&Z.startsWith(_.slice(0,-1))))})){m({status:"error",message:`Tipo de arquivo não permitido. Permitidos: ${i.join(", ")}`});return}}if(a&&j.size>a){m({status:"error",message:`Arquivo muito grande. Tamanho máximo: ${Tt(a)}`});return}if(!u){m({status:"error",message:"Preview: upload não disponível sem configuração."});return}m({status:"uploading",fileName:j.name,progress:0});try{if(w&&d)try{await d(w)}catch{}const S=await u(j,s??t,N=>{k.current&&m(R=>R.status==="uploading"?{...R,progress:Math.min(100,N)}:R)});if(!k.current)return;o.onChange(S),m({status:"done",uploadId:S,fileName:j.name,size:j.size})}catch{if(!k.current)return;m({status:"error",message:"Falha no upload. Tente novamente."})}},[u,d,w,s,t,o,i,a]),v=x.useCallback(j=>{var S;const b=(S=j.target.files)==null?void 0:S[0];b&&C(b),j.target.value=""},[C]),y=x.useCallback(()=>{w&&d&&d(w).catch(()=>{}),o.onChange(""),m({status:"idle"}),f.current&&(f.current.value="")},[o,w,d]);if(l.status==="done"||l.status==="idle"&&!!w){const j=l.status==="done"?l.fileName:"Arquivo enviado",b=l.status==="done"?l.size:null;return n.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-500 bg-green-500/5 px-4 py-3 gap-2",children:[n.jsxs("svg",{className:"shrink-0 text-green-500",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[n.jsx("rect",{width:"20",height:"20",rx:"4",fill:"currentColor",fillOpacity:"0.15"}),n.jsx("path",{d:"M5 10.5L8.5 14L15 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("span",{className:"text-sm font-medium truncate flex-1",children:j}),b!==null&&n.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Tt(b)}),!r&&n.jsx("button",{type:"button",onClick:y,className:"ml-2 shrink-0 text-muted-foreground hover:text-destructive transition-colors","aria-label":"Remover arquivo",children:"✕"})]})}if(l.status==="uploading"){const{fileName:j,progress:b}=l;return n.jsxs("div",{className:"rounded-lg border border-input px-4 py-3 space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-sm font-medium truncate flex-1",children:j}),n.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[b,"%"]})]}),n.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full bg-primary transition-all duration-200 rounded-full",style:{width:`${b}%`}})})]})}const B=l.status==="error";return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{role:"button",tabIndex:r?-1:0,"aria-label":"Selecionar arquivo",className:F.cn("flex items-center justify-center rounded-lg border-2 border-dashed px-4 py-6 transition-colors cursor-pointer",p?"border-primary bg-primary/5":B||c.error?"border-destructive bg-destructive/5":"border-input hover:border-muted-foreground hover:bg-muted/20",r&&"opacity-50 cursor-not-allowed"),onClick:()=>{var j;return!r&&((j=f.current)==null?void 0:j.click())},onKeyDown:j=>{var b;(j.key==="Enter"||j.key===" ")&&((b=f.current)==null||b.click())},onDragOver:j=>{j.preventDefault(),r||g(!0)},onDragLeave:()=>g(!1),onDrop:r?void 0:j=>{var S;j.preventDefault(),g(!1);const b=(S=j.dataTransfer.files)==null?void 0:S[0];b&&C(b)},onBlur:o.onBlur,children:[n.jsx("input",{ref:f,type:"file",onChange:v,disabled:r,className:"sr-only"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:p?"Solte o arquivo aqui":"Clique ou arraste um arquivo"})]}),B&&n.jsxs("p",{className:"text-sm text-destructive",children:[l.message," · ",n.jsx("button",{type:"button",className:"underline hover:no-underline",onClick:()=>m({status:"idle"}),children:"Tentar novamente"})]}),!B&&((E=c.error)==null?void 0:E.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Ps={cpf:t=>t.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"),telefone:t=>{const e=t.replace(/\D/g,"").slice(0,11);return e.length<=10?e.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{4})(\d)/,"$1-$2"):e.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{5})(\d)/,"$1-$2")},cep:t=>t.replace(/\D/g,"").slice(0,8).replace(/(\d{5})(\d)/,"$1-$2")},ge=({name:t,control:e,placeholder:r,maskType:s,disabled:i,readOnly:a})=>{var l;const{field:o,fieldState:c}=I.useController({name:t,control:e}),u=Ps[s||""],d=x.useCallback(m=>{o.onChange(u?u(m.target.value):m.target.value)},[o,u]);return n.jsxs("div",{className:"space-y-1",children:[n.jsx(F.Input,{name:o.name,value:o.value||"",onChange:d,onBlur:o.onBlur,placeholder:r,disabled:i,readOnly:a,className:F.cn(c.error&&"border-destructive focus-visible:ring-destructive")}),((l=c.error)==null?void 0:l.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},He=({name:t,control:e})=>{const{field:r}=I.useController({name:t,control:e});return n.jsx("input",{type:"hidden",...r,value:r.value??""})},Ht=t=>t.replace(/\D/g,""),Ls=t=>{const e=Ht(t).slice(0,8);return e.length<=5?e:`${e.slice(0,5)}-${e.slice(5)}`},zs=async(t,e)=>{const r=await fetch(`https://viacep.com.br/ws/${t}/json/`,{signal:e});if(!r.ok)throw new Error("Falha ao consultar CEP");return r.json()},lt=({name:t,control:e,placeholder:r="00000-000",disabled:s,readOnly:i,cepFillMap:a})=>{var v,y;const{field:o,fieldState:c}=I.useController({name:t,control:e}),{setValue:u}=I.useFormContext(),{cepLookup:d}=xe(),[l,m]=x.useState("idle"),[f,p]=x.useState(null),g=x.useRef(null),k=x.useRef(!0);x.useEffect(()=>()=>{var D;k.current=!1,(D=g.current)==null||D.abort()},[]);const w=x.useCallback(async()=>{var B;o.onBlur();const D=Ht(o.value??"");if(D.length===8){(B=g.current)==null||B.abort(),g.current=new AbortController,m("loading"),p(null);try{let E;if(d){const S=g.current;if(E=await d(D,S.signal),S.signal.aborted||!k.current)return}else{const S=await zs(D,g.current.signal);if(!k.current)return;if(S.erro){m("error"),p("CEP não encontrado");return}E={logradouro:S.logradouro,bairro:S.bairro,cidade:S.localidade,estado:S.uf}}if(!k.current)return;if(E.erro){m("error"),p("CEP não encontrado");return}const j=t.includes(".")?`${t.substring(0,t.lastIndexOf("."))}.`:"",b=(S,N,R)=>{if(!R)return;const W=a!=null&&a[S]?`${j}${a[S]}`:`${j}${N}`;u(W,R,{shouldDirty:!0,shouldValidate:!0})};b("logradouro","_address_logradouro",E.logradouro),b("bairro","_address_bairro",E.bairro),b("cidade","_address_cidade",E.cidade),b("estado","_address_estado",E.estado),m("success")}catch(E){if(E instanceof Error&&E.name==="AbortError"||!k.current)return;m("error"),p("Erro ao buscar CEP")}}},[o,d,u,t,a]),C=x.useCallback(D=>{o.onChange(Ls(D.target.value))},[o]);return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"relative",children:[n.jsx(F.Input,{name:o.name,value:o.value||"",onChange:C,onBlur:w,placeholder:r,disabled:s,readOnly:i,className:F.cn("pr-9",c.error&&"border-destructive focus-visible:ring-destructive")}),n.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:[l==="loading"&&n.jsx(A.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}),l==="success"&&n.jsx(A.Check,{className:"h-4 w-4 text-green-500"}),l==="error"&&n.jsx(A.AlertCircle,{className:"h-4 w-4 text-destructive"})]})]}),(((v=c.error)==null?void 0:v.message)||f)&&n.jsx("p",{className:"text-sm text-destructive",children:((y=c.error)==null?void 0:y.message)||f})]})},Ms=({field:t,control:e,nameOverride:r})=>{const s={name:r,control:e,placeholder:t.placeholder};switch(t.tipo){case h.FieldType.TEXTO:return n.jsx(re,{...s,type:"text"});case h.FieldType.EMAIL:return n.jsx(re,{...s,type:"email"});case h.FieldType.NUMBER:return n.jsx(re,{...s,type:"number"});case h.FieldType.TEXTAREA:return n.jsx(_e,{...s});case h.FieldType.SELECT:return n.jsx(We,{...s,options:t.opcoes??[]});case h.FieldType.RADIO:return n.jsx(st,{...s,options:t.opcoes??[]});case h.FieldType.CHECKBOX:return n.jsx(qe,{name:r,control:e,label:t.label});case h.FieldType.CHECKBOX_GROUP:return n.jsx(rt,{...s,options:t.opcoes??[]});case h.FieldType.DATE:return n.jsx(je,{...s,validacao:t.validacao});case h.FieldType.DATETIME:return n.jsx(je,{...s,isDatetime:!0,validacao:t.validacao});case h.FieldType.FILE:return n.jsx(ct,{name:r,control:e});case h.FieldType.TELEFONE:return n.jsx(ge,{...s,maskType:"telefone"});case h.FieldType.CPF:return n.jsx(ge,{...s,maskType:"cpf"});case h.FieldType.CEP:return n.jsx(lt,{name:r,control:e,placeholder:t.placeholder});case h.FieldType.HIDDEN:return n.jsx(He,{name:r,control:e});default:return console.error(`[DFFieldArray] Tipo de sub-campo "${t.tipo}" não suportado em FIELD_ARRAY. Usando DFTextField como fallback.`),n.jsx(re,{...s,type:"text"})}},Gt=({name:t,control:e,subFields:r=[],minItems:s=1,maxItems:i,itemLabel:a="Item",addLabel:o})=>{var w;const{fields:c,append:u,remove:d}=I.useFieldArray({control:e,name:t}),{errors:l}=I.useFormState({control:e}),m=(w=l[t])==null?void 0:w.message,f=x.useCallback(()=>{const C={};for(const v of r)v.initialValue!==void 0?C[v.nome]=v.initialValue:v.defaultValue!==void 0&&(C[v.nome]=v.defaultValue);return C},[r]);x.useEffect(()=>{if(c.length<s)for(let C=c.length;C<s;C++)u(f())},[s]);const p=[...r].sort((C,v)=>C.ordem-v.ordem),g=!i||c.length<i,k=o??`Adicionar ${a.toLowerCase()}`;return n.jsxs("div",{className:"space-y-3",children:[c.map((C,v)=>n.jsxs("div",{className:"rounded-lg border border-input p-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary shrink-0",children:v+1}),n.jsxs("span",{className:"text-sm font-semibold",children:[a," ",v+1]})]}),c.length>s&&n.jsx(F.Button,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(v),"aria-label":`Remover ${a.toLowerCase()} ${v+1}`,className:"text-muted-foreground hover:text-destructive",children:n.jsx(A.Trash2,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"grid grid-cols-12 gap-4",children:p.map(y=>{const D=`${t}.${v}.${y.nome}`,E=`span ${y.tamanho??12}`,j=n.jsx(Ms,{field:y,control:e,nameOverride:D});return y.tipo===h.FieldType.CHECKBOX||y.tipo===h.FieldType.HIDDEN?n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:E},children:j},y.id):n.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:E},children:[n.jsxs("label",{className:"font-medium flex items-center gap-1 text-sm text-foreground",children:[y.label,y.obrigatorio&&n.jsx("span",{className:"text-destructive",children:"*"})]}),j,y.hint&&n.jsx("p",{className:"text-xs text-muted-foreground",children:y.hint})]},y.id)})})]},C.id)),g&&n.jsxs(F.Button,{type:"button",variant:"outline",className:"w-full",onClick:()=>u(f()),children:[n.jsx(A.Plus,{className:"w-4 h-4"}),k]}),i&&n.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",i," ",a.toLowerCase(),i>1?"s":""]}),m&&n.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[n.jsx(A.AlertCircle,{className:"w-4 h-4 shrink-0"}),m]})]})},Et=t=>`R$ ${(t/100).toFixed(2).replace(".",",")}`,$s=(t,e)=>{const r=new Date(t.slice(0,10)+"T00:00:00Z"),s=new Date(e.slice(0,10)+"T00:00:00Z");return Math.round((s.getTime()-r.getTime())/864e5)+1},Us=(t,e)=>{const r=[],s=new Date(t.slice(0,10)+"T00:00:00Z"),i=new Date(e.slice(0,10)+"T00:00:00Z");let a=0;for(;s<=i&&a<60;)r.push(s.toISOString().slice(0,10)),s.setUTCDate(s.getUTCDate()+1),a++;return r},Vs=t=>{const[e,r,s]=t.split("-").map(Number),i=new Date(Date.UTC(e,r-1,s)),a=String(s).padStart(2,"0"),o=String(r).padStart(2,"0"),c=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(i),u=c.charAt(0).toUpperCase()+c.slice(1);return`${a}/${o} - ${u}`},_s=(t,e)=>{const r=s=>{const[i,a,o]=s.slice(0,10).split("-");return`${o}/${a}/${i}`};return`${r(t)} a ${r(e)}`},Kt=({name:t,control:e})=>{var ne;const{field:r,fieldState:s}=I.useController({name:t,control:e}),{externalData:i={}}=xe(),a=r.value??null,o=(ne=s.error)==null?void 0:ne.message,c=P=>i[`evento.${P}`]??i[P],u=c("dataInicioEvento")??"",d=c("dataFimEvento")??"",l=Number(c("valor")??0),m=Number(c("valorPorDia")??0),f=c("vagasTotal"),p=c("vagasPorDia"),g=c("vagasMasculinas"),k=c("vagasFemininas"),w=f!=null?Number(f):null,C=p!=null?Number(p):null,v=g!=null?Number(g):null,y=k!=null?Number(k):null,D=u&&d?Us(u,d):[],E=(u&&d?$s(u,d):0)>1,j=v!=null&&v>0&&y!=null&&y>0,b=v!=null&&y==null?"masculino":y!=null&&v==null?"feminino":null,S=(a==null?void 0:a.tipo)??null,N=(a==null?void 0:a.data)??null,R=(a==null?void 0:a.genero)??null,W=x.useRef(a);W.current=a;const Z=x.useRef(r.onChange);Z.current=r.onChange,x.useEffect(()=>{var P,X,be;b&&((P=W.current)==null?void 0:P.genero)!==b&&Z.current({tipo:((X=W.current)==null?void 0:X.tipo)??null,data:((be=W.current)==null?void 0:be.data)??null,genero:b})},[b]);const ee=P=>{const X={tipo:P,data:null};(j||b)&&(X.genero=R??b??void 0),r.onChange(X)},te=P=>{const X={tipo:"por_dia",data:P};(j||b)&&(X.genero=R??b??void 0),r.onChange(X)},_=P=>{r.onChange({tipo:S,data:N,genero:P})},se=P=>S===P;return n.jsxs("div",{className:"space-y-3",children:[j&&n.jsxs("div",{className:"flex items-center gap-2 px-1",children:[n.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Você é:"}),n.jsx("div",{className:"flex gap-2",children:["masculino","feminino"].map(P=>n.jsx("button",{type:"button",onClick:()=>_(P),className:F.cn("px-3 py-1 rounded-full text-xs font-medium border transition-all",R===P?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:border-primary/50"),children:P==="masculino"?"Masculino":"Feminino"},P))})]}),n.jsxs("button",{type:"button",onClick:()=>ee("todos_os_dias"),className:F.cn("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",se("todos_os_dias")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[n.jsx("div",{className:F.cn("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",se("todos_os_dias")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.jsx(A.CalendarCheck2,{className:"w-4 h-4"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-semibold text-sm",children:"Participar todos os dias"}),u&&d?n.jsx("p",{className:"text-xs text-muted-foreground",children:_s(u,d)}):n.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Datas do evento"})]}),n.jsxs("div",{className:"text-right shrink-0",children:[l>0&&n.jsx("p",{className:F.cn("font-bold text-sm",se("todos_os_dias")?"text-primary":"text-foreground"),children:Et(l)}),w!=null&&w>0&&n.jsxs("p",{className:"text-xs flex items-center justify-end gap-1 text-muted-foreground",children:[n.jsx(A.Users,{className:"w-3 h-3"}),w," vagas disponíveis"]})]})]}),E?n.jsxs("button",{type:"button",onClick:()=>ee("por_dia"),className:F.cn("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",se("por_dia")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[n.jsx("div",{className:F.cn("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",se("por_dia")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.jsx(A.CalendarDays,{className:"w-4 h-4"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-semibold text-sm",children:"Participar um dia"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado abaixo"})]}),n.jsxs("div",{className:"text-right shrink-0",children:[m>0&&n.jsx("p",{className:F.cn("font-bold text-sm",se("por_dia")?"text-primary":"text-foreground"),children:Et(m)}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"por dia"})]})]}):u?n.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg border border-input bg-muted/30",children:[n.jsx(A.Info,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-muted-foreground"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:'Este evento ocorre em apenas 1 dia — a opção "Participar um dia" não é necessária.'})]}):null,S==="por_dia"&&n.jsxs("div",{className:"pl-2 space-y-2",children:[n.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Selecione o dia:"}),D.length===0?n.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nenhuma data configurada no evento"}):D.map(P=>n.jsxs("button",{type:"button",onClick:()=>te(P),className:F.cn("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",N===P?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:F.cn("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center transition-colors",N===P?"border-primary bg-primary":"border-input"),children:N===P&&n.jsx("span",{className:"w-2 h-2 rounded-full bg-white"})}),n.jsx("span",{className:"text-sm",children:Vs(P)})]}),C!=null&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:[C," vagas"]})]},P))]}),o&&n.jsx("p",{className:"text-sm text-destructive",children:o})]})},At=.0315,It=.124,Bt=7,Rt=12,Xt=[{id:"pix",label:"PIX",description:"Transferência instantânea (à vista)",Icon:A.Smartphone,taxa:0},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:A.Banknote,taxa:0},{id:"cartao",label:"Cartão de Crédito",description:"Débito ou crédito na maquininha",Icon:A.CreditCard,taxa:At,taxaLabel:`Taxa: ${(At*100).toFixed(2).replace(".",",")}%`}],Yt=[{id:"pix",label:"PIX à Vista",description:"Pagamento instantâneo sem parcelamento",Icon:A.Smartphone,taxa:0},{id:"pix_parcelado",label:"PIX Parcelado",description:`Parcelado em até ${Bt}x sem juros`,Icon:A.Smartphone,taxa:0,parcelas:Bt},{id:"cartao",label:"Cartão de Crédito",description:`Parcelado em até ${Rt}x`,Icon:A.CreditCard,taxa:It,parcelas:Rt,taxaLabel:`Taxa: ${(It*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:A.Banknote,taxa:0}],Le=t=>`R$ ${(t/100).toFixed(2).replace(".",",")}`,Ot=(t,e)=>Math.round(t*(1+e)*100)/100,Ws=(t,e)=>Math.round(t/e*100)/100,Jt=({name:t,control:e,relatedFieldName:r="tipo_participacao"})=>{var v;const{field:s,fieldState:i}=I.useController({name:t,control:e}),{externalData:a={},paymentMethodOptions:o}=xe(),c=s.value??null,u=(v=i.error)==null?void 0:v.message,d=I.useWatch({control:e,name:r}),l=(d==null?void 0:d.tipo)??null,m=y=>a[`evento.${y}`]??a[y],f=Number(m("valor")??0),p=Number(m("valorPorDia")??0),g=l==="por_dia"&&p>0?p:f,k=l==="por_dia"?(o==null?void 0:o.porDia)??Xt:(o==null?void 0:o.todosOsDias)??Yt,w=l==="por_dia"?(()=>{if(!(d!=null&&d.data))return"Um dia";const y=d.data.split("-");if(y.length===3){const[D,B,E]=y;return`${E}/${B}/${D}`}return d.data})():"Todos os dias",C=y=>{if(y.disabled)return;const D=Ot(g,y.taxa),B={metodo:y.id,valorTotal:D};y.parcelas&&(B.parcelas=y.parcelas),s.onChange(B)};return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-input px-4 py-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Tipo de participação"}),n.jsx("p",{className:"font-semibold",children:w})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Valor base"}),n.jsx("p",{className:"text-lg font-bold text-primary",children:Le(g)})]})]}),n.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-input bg-muted/30 px-3 py-2.5",children:[n.jsx(A.Info,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),n.jsxs("p",{className:"text-xs",children:[n.jsx("span",{className:"font-bold",children:"Importante:"})," Para validar a inscrição e garantir sua vaga, o pagamento deve ser realizado no ato da inscrição."]})]}),n.jsx("p",{className:"text-sm font-semibold text-primary",children:"Selecione a forma de pagamento:"}),n.jsx("div",{className:"space-y-3",children:k.map(y=>{const{Icon:D}=y,B=(c==null?void 0:c.metodo)===y.id,E=Ot(g,y.taxa),j=!!y.parcelas&&y.parcelas>1,b=j?Ws(E,y.parcelas):null;return n.jsxs("button",{type:"button",disabled:y.disabled,onClick:()=>C(y),className:F.cn("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all",B?"border-primary bg-primary/5":"border-input hover:border-primary/50",y.disabled&&"opacity-50 cursor-not-allowed"),children:[n.jsx("div",{className:F.cn("flex items-center justify-center w-10 h-10 rounded-lg shrink-0 transition-colors",B?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.jsx(D,{className:"h-5 w-5"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-semibold text-sm leading-tight",children:y.label}),n.jsx("p",{className:"text-xs text-muted-foreground",children:y.description}),y.taxaLabel&&n.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["* ",y.taxaLabel]}),y.taxa>0&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",Le(E)]})]}),n.jsx("div",{className:"text-right shrink-0",children:j?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-xs text-muted-foreground",children:[y.parcelas,"x de"]}),n.jsx("p",{className:"text-base font-bold text-primary",children:Le(b)})]}):n.jsx("p",{className:"text-base font-bold text-primary",children:Le(E)})})]},y.id)})}),u&&n.jsx("p",{className:"text-xs text-destructive",children:u})]})},Qt=({name:t,control:e,label:r,termoTexto:s,termoPdfUrl:i,termoPdfUploadId:a})=>{var E;const{field:o,fieldState:c}=I.useController({name:t,control:e}),{resolveTermsUploadUrl:u}=xe(),d=!!c.error,l=(E=c.error)==null?void 0:E.message,[m,f]=x.useState(null),[p,g]=x.useState(!1),[k,w]=x.useState(!1),C=x.useRef(null);x.useEffect(()=>{var j;k&&((j=C.current)==null||j.focus())},[k]),x.useEffect(()=>{if(!a||!u){f(null);return}let j=!1;return g(!0),u(a).then(b=>{j||f(b)}).catch(()=>{j||f(null)}).finally(()=>{j||g(!1)}),()=>{j=!0}},[a,u]);const v=o.value==="accepted",y=m||i||null,D=!!(s||y||a),B=!!y;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:F.cn("rounded-lg border p-4 space-y-4 transition-colors",d?"border-destructive bg-destructive/5":v?"border-green-500 bg-green-500/5":"border-input"),children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(A.ScrollText,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"text-sm font-medium",children:r||"Termos e condições"})]}),D?n.jsxs(F.Button,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",disabled:p,onClick:()=>w(!0),children:[p?n.jsx(A.Loader2,{className:"h-3 w-3 animate-spin"}):n.jsx(A.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]}):n.jsx("span",{className:"text-xs text-muted-foreground italic",children:a&&p?"Carregando PDF...":"Conteúdo não configurado"})]}),n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[n.jsx(F.Checkbox,{className:"mt-0.5",checked:v,onCheckedChange:j=>o.onChange(j?"accepted":"")}),n.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito ",r?`"${r}"`:"os termos e condições"]}),v&&n.jsx(A.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]}),d&&n.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[n.jsx(A.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),l||"Você precisa aceitar os termos para continuar"]}),k&&n.jsx("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":"Termos e condições",tabIndex:-1,className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 outline-none",onClick:()=>w(!1),onKeyDown:j=>{j.key==="Escape"&&w(!1)},children:n.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] rounded-xl overflow-hidden flex flex-col bg-background shadow-xl",onClick:j=>j.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-input",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(A.ScrollText,{className:"h-4 w-4"}),n.jsx("span",{className:"font-semibold",children:"Termos e condições"})]}),n.jsx(F.Button,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(!1),children:n.jsx(A.X,{className:"h-4 w-4"})})]}),n.jsx("div",{className:"flex-1 overflow-auto p-4",children:B?n.jsx("iframe",{src:y,className:"w-full rounded border",style:{height:"62vh"},title:"Termos e condições",sandbox:"allow-scripts"}):n.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:s})})]})})]})},qs=({name:t,control:e,placeholder:r,disabled:s,readOnly:i})=>{var l;const{field:a,fieldState:o}=I.useController({name:t,control:e}),[c,u]=x.useState(!1),d=!!o.error;return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"relative",children:[n.jsx(F.Input,{...a,value:a.value??"",type:c?"text":"password",placeholder:r,disabled:s,readOnly:i,className:F.cn("pr-10",d&&"border-destructive focus-visible:ring-destructive")}),n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>u(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":c?"Ocultar senha":"Mostrar senha",children:c?n.jsx(A.EyeOff,{size:16}):n.jsx(A.Eye,{size:16})})]}),((l=o.error)==null?void 0:l.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},er=({name:t,control:e,label:r,disabled:s,readOnly:i})=>{var u;const{field:a,fieldState:o}=I.useController({name:t,control:e}),c=!!a.value;return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[n.jsx(F.Switch,{checked:c,onCheckedChange:d=>!i&&a.onChange(d),disabled:s||i,onBlur:a.onBlur}),n.jsx("span",{className:"text-sm leading-none",children:r})]}),((u=o.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},Zs=({name:t,control:e,minValue:r=0,maxValue:s=100,step:i=1,disabled:a,readOnly:o})=>{var l;const{field:c,fieldState:u}=I.useController({name:t,control:e}),d=c.value??r;return x.useEffect(()=>{(c.value===void 0||c.value===null)&&c.onChange(r)},[]),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(F.Slider,{min:r,max:s,step:i,value:[d],onValueChange:m=>!o&&c.onChange(m[0]),disabled:a||o,className:"flex-1"}),n.jsx("span",{className:"text-sm font-medium text-primary min-w-[3rem] text-right tabular-nums",children:d})]}),n.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[n.jsx("span",{children:r}),n.jsx("span",{children:s})]}),((l=u.error)==null?void 0:l.message)&&n.jsx("p",{className:"text-sm text-destructive",children:u.error.message})]})},et=t=>/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t),Hs=({name:t,control:e,disabled:r,readOnly:s})=>{var d;const{field:i,fieldState:a}=I.useController({name:t,control:e}),o=i.value||"#000000",[c,u]=x.useState(o);return x.useEffect(()=>{u(o)},[o]),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("input",{type:"color",value:et(o)?o:"#000000",disabled:r||s,onChange:l=>i.onChange(l.target.value),className:"h-10 w-14 cursor-pointer rounded-lg border border-input bg-transparent p-1 disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx(F.Input,{type:"text",value:c,readOnly:s,disabled:r,onChange:l=>{const m=l.target.value;u(m),et(m)&&i.onChange(m.toUpperCase())},onBlur:()=>{et(c)||u(o),i.onBlur()},className:F.cn("flex-1 font-mono uppercase",a.error&&"border-destructive focus-visible:ring-destructive"),maxLength:7,placeholder:"#000000"})]}),((d=a.error)==null?void 0:d.message)&&n.jsx("p",{className:"text-sm text-destructive",children:a.error.message})]})},Gs=({name:t,control:e,options:r,placeholder:s,disabled:i,readOnly:a})=>{var b,S;const{field:o,fieldState:c}=I.useController({name:t,control:e}),[u,d]=x.useState(""),[l,m]=x.useState(!1),[f,p]=x.useState(-1),g=x.useRef(null),k=x.useRef(null),w=`autocomplete-${t}-listbox`,C=((b=r.find(N=>N.valor===o.value))==null?void 0:b.label)??"",v=u.length>0?r.filter(N=>N.label.toLowerCase().includes(u.toLowerCase())):r;x.useEffect(()=>{const N=R=>{g.current&&!g.current.contains(R.target)&&(m(!1),d(""),p(-1))};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const y=()=>{m(!1),d(""),p(-1)};x.useEffect(()=>{if(f<0||!k.current)return;const N=k.current.querySelector(`[id="${w}-option-${f}"]`);N==null||N.scrollIntoView({block:"nearest"})},[f,w]);const D=N=>{N.disabled||(o.onChange(N.valor),y())},B=()=>{o.onChange(""),d(""),p(-1)},E=N=>{if(!l){(N.key==="ArrowDown"||N.key==="ArrowUp")&&(N.preventDefault(),m(!0),p(0));return}switch(N.key){case"ArrowDown":N.preventDefault(),p(R=>R<v.length-1?R+1:R);break;case"ArrowUp":N.preventDefault(),p(R=>R>0?R-1:0);break;case"Enter":N.preventDefault(),f>=0&&v[f]&&!v[f].disabled&&D(v[f]);break;case"Escape":N.preventDefault(),y();break;case"Tab":y();break}},j=l&&f>=0?`${w}-option-${f}`:void 0;return n.jsxs("div",{className:"space-y-1",ref:g,children:[n.jsxs("div",{className:"relative",children:[n.jsx(F.Input,{type:"text",role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-controls":w,"aria-activedescendant":j,value:l?u:C,placeholder:s??"Buscar...",disabled:i,readOnly:a,onChange:N=>{d(N.target.value),p(-1),m(!0)},onFocus:()=>!a&&m(!0),onKeyDown:E,className:F.cn("pr-8",c.error&&"border-destructive focus-visible:ring-destructive"),autoComplete:"off"}),n.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:o.value?n.jsx("button",{type:"button",onClick:B,className:"text-[var(--t-text-muted)] hover:text-[var(--t-text)]",tabIndex:-1,"aria-label":"Limpar seleção",children:n.jsx(A.X,{size:14})}):n.jsx(A.ChevronDown,{size:16,className:"text-muted-foreground pointer-events-none","aria-hidden":"true"})}),l&&!i&&!a&&n.jsx("ul",{role:"listbox",id:w,ref:k,"aria-label":"Opções disponíveis",className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-input bg-popover shadow-lg",children:v.length===0?n.jsx("li",{role:"option","aria-selected":!1,className:"px-3 py-2 text-sm text-muted-foreground",children:"Nenhuma opção encontrada"}):v.map((N,R)=>n.jsx("li",{id:`${w}-option-${R}`,role:"option","aria-selected":o.value===N.valor,"aria-disabled":N.disabled,onMouseDown:()=>D(N),className:["flex cursor-pointer items-center px-3 py-2 text-sm",N.disabled?"cursor-not-allowed opacity-40":R===f?"bg-accent":"hover:bg-accent",o.value===N.valor?"font-medium text-primary":"text-foreground"].join(" "),children:N.label},N.valor))})]}),((S=c.error)==null?void 0:S.message)&&n.jsx("p",{className:"text-sm text-destructive",role:"alert",children:c.error.message})]})},tr=({name:t,control:e,placeholder:r,disabled:s,readOnly:i})=>{var u;const{field:a,fieldState:o}=I.useController({name:t,control:e}),c=!!o.error;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(F.Input,{...a,value:a.value??"",type:"time",placeholder:r,disabled:s,readOnly:i,className:F.cn(c&&"border-destructive focus-visible:ring-destructive")}),((u=o.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},Ks=({name:t,control:e,startLabel:r="Data inicial",endLabel:s="Data final",disabled:i,readOnly:a})=>{var m;const{field:o,fieldState:c}=I.useController({name:t,control:e}),u=o.value??{},d=(f,p)=>{o.onChange({...u,[f]:p})},l=!!c.error;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(F.Label,{children:r}),n.jsx(F.Input,{type:"date",value:u.start??"",disabled:i,readOnly:a,onChange:f=>d("start",f.target.value),max:u.end??void 0,className:F.cn(l&&"border-destructive focus-visible:ring-destructive")})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(F.Label,{children:s}),n.jsx(F.Input,{type:"date",value:u.end??"",disabled:i,readOnly:a,onChange:f=>d("end",f.target.value),min:u.start??void 0,className:F.cn(l&&"border-destructive focus-visible:ring-destructive")})]})]}),((m=c.error)==null?void 0:m.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Xs=({name:t,control:e,maxRating:r=5,disabled:s,readOnly:i})=>{var d;const{field:a,fieldState:o}=I.useController({name:t,control:e}),c=a.value??0,u=Array.from({length:r},(l,m)=>m+1);return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[u.map(l=>n.jsx("button",{type:"button",disabled:s||i,onClick:()=>a.onChange(l===c?0:l),className:"transition-transform hover:scale-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":`${l} estrela${l>1?"s":""}`,children:n.jsx(A.Star,{size:24,className:"transition-colors",fill:l<=c?"var(--color-primary)":"transparent",stroke:l<=c?"var(--color-primary)":"currentColor"})},l)),c>0&&n.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c,"/",r]})]}),((d=o.error)==null?void 0:d.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},Ys=({field:t,name:e,control:r,disabled:s,readOnly:i})=>{const a=s||t.isDisabled,o=i||t.isReadOnly;switch(t.tipo){case h.FieldType.EMAIL:return n.jsx(re,{name:e,control:r,type:"email",placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.NUMBER:return n.jsx(re,{name:e,control:r,type:"number",placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.PASSWORD:return n.jsx(re,{name:e,control:r,type:"password",placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.TELEFONE:return n.jsx(ge,{name:e,control:r,maskType:"telefone",placeholder:t.placeholder??"(00) 00000-0000",disabled:a,readOnly:o});case h.FieldType.CPF:return n.jsx(ge,{name:e,control:r,maskType:"cpf",placeholder:t.placeholder??"000.000.000-00",disabled:a,readOnly:o});case h.FieldType.CEP:return n.jsx(ge,{name:e,control:r,maskType:"cep",placeholder:t.placeholder??"00000-000",disabled:a,readOnly:o});case h.FieldType.TEXTAREA:return n.jsx(_e,{name:e,control:r,placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.SELECT:return n.jsx(We,{name:e,control:r,options:t.opcoes??[],placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.CHECKBOX:return n.jsx(qe,{name:e,control:r,label:t.label??"",disabled:a,readOnly:o});case h.FieldType.SWITCH:return n.jsx(er,{name:e,control:r,label:t.label??"",disabled:a,readOnly:o});case h.FieldType.DATE:return n.jsx(je,{name:e,control:r,disabled:a,readOnly:o});case h.FieldType.TIME:return n.jsx(tr,{name:e,control:r,disabled:a,readOnly:o});case h.FieldType.HIDDEN:return n.jsx(He,{name:e,control:r});default:return n.jsx(re,{name:e,control:r,type:"text",placeholder:t.placeholder,disabled:a,readOnly:o})}},Js=({name:t,control:e,subSchema:r,disabled:s,readOnly:i})=>{if(!r||r.fields.length===0)return null;const a=[...r.fields].sort((o,c)=>o.ordem-c.ordem);return n.jsxs("div",{className:"rounded-xl border border-input bg-muted/30 p-4 space-y-4",children:[r.titulo&&n.jsx("h4",{className:"text-sm font-semibold text-muted-foreground",children:r.titulo}),n.jsx("div",{className:"grid grid-cols-12 gap-4",children:a.map(o=>{const c=`${t}.${o.nome}`,u=o.tipo===h.FieldType.CHECKBOX||o.tipo===h.FieldType.SWITCH||o.tipo===h.FieldType.HIDDEN,d=o.tamanho??6;return n.jsxs("div",{className:`col-span-${d}`,children:[!u&&n.jsxs("label",{className:"mb-1 block text-sm font-medium text-foreground",children:[o.label,o.obrigatorio&&n.jsx("span",{className:"text-destructive",children:" *"})]}),n.jsx(Ys,{field:o,name:c,control:e,disabled:s,readOnly:i})]},o.id)})})]})},rr=({field:t,control:e,nameOverride:r})=>{var c,u;const s=r??t.nome,{componentMapper:i}=xe(),a=i==null?void 0:i[t.tipo];if(a)return n.jsx(a,{name:s,control:e,field:t});const o={name:s,control:e,placeholder:t.placeholder,disabled:t.isDisabled,readOnly:t.isReadOnly};switch(t.tipo){case h.FieldType.TEXTO:return n.jsx(re,{...o,type:"text"});case h.FieldType.EMAIL:return n.jsx(re,{...o,type:"email"});case h.FieldType.NUMBER:return n.jsx(re,{...o,type:"number"});case h.FieldType.PASSWORD:return n.jsx(qs,{...o});case h.FieldType.TEXTAREA:return n.jsx(_e,{...o});case h.FieldType.SELECT:return n.jsx(We,{...o,options:t.opcoes??[]});case h.FieldType.AUTOCOMPLETE:return n.jsx(Gs,{...o,options:t.opcoes??[]});case h.FieldType.SWITCH:return n.jsx(er,{name:s,control:e,label:t.label,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.SLIDER:return n.jsx(Zs,{name:s,control:e,minValue:t.minValue,maxValue:t.maxValue,step:t.step,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.RATING:return n.jsx(Xs,{name:s,control:e,maxRating:t.maxRating,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.COLOR:return n.jsx(Hs,{name:s,control:e,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.TIME:return n.jsx(tr,{...o});case h.FieldType.DATE_RANGE:return n.jsx(Ks,{name:s,control:e,startLabel:t.dateRangeStartLabel,endLabel:t.dateRangeEndLabel,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.RADIO:return n.jsx(st,{...o,options:t.opcoes??[]});case h.FieldType.CHECKBOX:return n.jsx(qe,{name:s,control:e,label:t.label,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.CHECKBOX_GROUP:return n.jsx(rt,{...o,options:t.opcoes??[]});case h.FieldType.DATE:return n.jsx(je,{name:s,control:e,disabled:t.isDisabled,readOnly:t.isReadOnly,validacao:t.validacao});case h.FieldType.DATETIME:return n.jsx(je,{name:s,control:e,isDatetime:!0,disabled:t.isDisabled,readOnly:t.isReadOnly,validacao:t.validacao});case h.FieldType.FILE:return n.jsx(ct,{name:s,control:e,disabled:t.isDisabled,fileTypes:(c=t.validacao)==null?void 0:c.fileTypes,maxFileSize:(u=t.validacao)==null?void 0:u.maxFileSize});case h.FieldType.TELEFONE:return n.jsx(ge,{...o,maskType:"telefone"});case h.FieldType.CPF:return n.jsx(ge,{...o,maskType:"cpf"});case h.FieldType.CEP:return n.jsx(lt,{name:s,control:e,placeholder:t.placeholder,disabled:t.isDisabled,readOnly:t.isReadOnly,cepFillMap:t.cepFillMap});case h.FieldType.HIDDEN:return n.jsx(He,{name:s,control:e});case h.FieldType.PARTICIPATION_TYPE:return n.jsx(Kt,{name:s,control:e});case h.FieldType.PAYMENT_METHOD:return n.jsx(Jt,{name:s,control:e,relatedFieldName:t.relatedFieldName});case h.FieldType.TERMS:return n.jsx(Qt,{name:s,control:e,label:t.label,termoTexto:t.termoTexto,termoPdfUrl:t.termoPdfUrl,termoPdfUploadId:t.termoPdfUploadId});case h.FieldType.FIELD_ARRAY:return n.jsx(Gt,{name:s,control:e,subFields:t.subFields,minItems:t.minItems,maxItems:t.maxItems,itemLabel:t.itemLabel,addLabel:t.addLabel});case h.FieldType.SUB_FORM:return n.jsx(Js,{name:s,control:e,subSchema:t.subSchema,disabled:t.isDisabled,readOnly:t.isReadOnly});default:return n.jsx(re,{...o,type:"text"})}},Qs=({container:t,control:e})=>{var k;const{externalData:r={},fieldResolvers:s}=xe(),i=t.icone?Ue[t.icone]:void 0,a=r,o=x.useMemo(()=>Ve(t,a),[t,JSON.stringify(a)]),c=x.useMemo(()=>[...o.campos].sort((w,C)=>w.ordem-C.ordem),[o.campos]),u=I.useWatch({control:e}),{wrapperClass:d,wrapperStyle:l,headerClass:m,headerStyle:f,tmpl:p}=Ut(),g=w=>{if(!h.evaluateFieldCondition(w.condicional,u,r))return null;let v=w;if(w.resolvePropsKey&&(s!=null&&s[w.resolvePropsKey])){const j=s[w.resolvePropsKey](w,u,r);v={...w,...j}}if(v.opcoesFromVar){const j=r[v.opcoesFromVar];Array.isArray(j)&&(v={...v,opcoes:j.map(b=>typeof b=="string"?{valor:b,label:b}:b&&typeof b=="object"&&"valor"in b&&"label"in b?b:{valor:String(b),label:String(b)})})}const y=v.tamanho??12,D=v.inicioColuna,B=D?`${D} / span ${y}`:`span ${y}`,E=n.jsx(rr,{field:v,control:e});return v.tipo===h.FieldType.CHECKBOX||v.tipo===h.FieldType.HIDDEN||v.tipo===h.FieldType.SWITCH?n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:B},children:E},v.id):n.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:B},children:[n.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[v.label,v.obrigatorio&&n.jsx("span",{className:"text-destructive",children:"*"})]}),E,v.hint&&n.jsx("p",{className:"text-xs text-muted-foreground",children:v.hint})]},v.id)};return n.jsxs("div",{className:d,style:l,children:[(o.titulo||i)&&n.jsx("div",{className:m,style:f,children:n.jsxs("div",{className:"flex items-center gap-3",children:[i&&n.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:n.jsx(i,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),n.jsxs("div",{children:[n.jsx("h3",{className:((k=p.typography)==null?void 0:k.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:o.titulo}),o.descricao&&n.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:o.descricao})]})]})}),n.jsx("div",{className:"p-6 grid grid-cols-12 gap-4",children:c.map(g)})]})},en=({container:t,control:e})=>{var j;const{externalData:r={}}=xe(),s=t.nome??"__invalid__",i=t.minItems??1,a=t.maxItems,o=t.itemLabel??"Item",c=t.icone?Ue[t.icone]:void 0,u=r,d=x.useMemo(()=>Ve(t,u),[t,JSON.stringify(u)]),l=x.useMemo(()=>[...d.campos].sort((b,S)=>b.ordem-S.ordem),[d.campos]),m=x.useCallback(()=>{const b={};for(const S of l)S.initialValue!==void 0?b[S.nome]=typeof S.initialValue=="string"?K(S.initialValue,u):S.initialValue:S.defaultValue!==void 0&&(b[S.nome]=S.defaultValue);return b},[l,u]),{fields:f,append:p,remove:g}=I.useFieldArray({control:e,name:s});x.useEffect(()=>{if(t.nome&&f.length<i)for(let b=f.length;b<i;b++)p(m())},[i]);const k=I.useWatch({control:e}),w=x.useMemo(()=>{const b=k[s];return Array.isArray(b)?b:[]},[k,s]),{wrapperClass:C,wrapperStyle:v,headerClass:y,headerStyle:D,tmpl:B}=Ut();if(!t.nome)return console.error("[RepeatableContainerRenderer] container.nome é obrigatório para containers repetíveis. Container id:",t.id),null;const E=(b,S)=>{const N=w[S]??{};if(!h.evaluateFieldCondition(b.condicional,N,r))return null;const W=`${s}.${S}.${b.nome}`,Z=b.tamanho??12,ee=b.inicioColuna,te=ee?`${ee} / span ${Z}`:`span ${Z}`,_=n.jsx(rr,{field:b,control:e,nameOverride:W});return b.tipo===h.FieldType.CHECKBOX||b.tipo===h.FieldType.HIDDEN?n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:te},children:_},`${b.id}-${S}`):n.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:te},children:[n.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[b.label,b.obrigatorio&&n.jsx("span",{className:"text-destructive",children:"*"})]}),_,b.hint&&n.jsx("p",{className:"text-xs text-muted-foreground",children:b.hint})]},`${b.id}-${S}`)};return n.jsxs("div",{className:C,style:v,children:[(d.titulo||c)&&n.jsx("div",{className:y,style:D,children:n.jsxs("div",{className:"flex items-center gap-3",children:[c&&n.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:n.jsx(c,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),n.jsxs("div",{children:[n.jsx("h3",{className:((j=B.typography)==null?void 0:j.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:d.titulo}),d.descricao&&n.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:d.descricao})]})]})}),n.jsxs("div",{className:"p-6 space-y-4",children:[f.map((b,S)=>n.jsxs("div",{className:"border border-input rounded-lg p-4 bg-muted/30",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shrink-0 bg-primary text-primary-foreground",children:S+1}),n.jsxs("span",{className:"text-sm font-semibold",children:[o," ",S+1]})]}),f.length>i&&n.jsx("button",{type:"button",onClick:()=>g(S),className:"inline-flex items-center justify-center rounded-md p-1.5 text-destructive hover:bg-destructive/10 transition-colors","aria-label":"Remover item",children:n.jsx(A.Trash2,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"grid grid-cols-12 gap-4",children:l.map(N=>E(N,S))})]},b.id)),(!a||f.length<a)&&n.jsxs("button",{type:"button",className:"w-full flex items-center justify-center gap-2 py-2 px-4 border border-input rounded-lg text-sm hover:bg-accent transition-colors",onClick:()=>p(m()),children:[n.jsx(A.Plus,{className:"w-4 h-4"}),"Adicionar ",o.toLowerCase()]}),a&&n.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",a," ",o.toLowerCase(),a>1?"s":""]})]})]})},sr=t=>t.container.repeatable&&t.container.nome?n.jsx(en,{...t}):n.jsx(Qs,{...t}),nr=({step:t,control:e,externalData:r={}})=>{const s=x.useMemo(()=>[...t.containers].sort((a,o)=>a.ordem-o.ordem),[t.containers]),i=I.useWatch({control:e});return n.jsx("div",{className:"grid grid-cols-12 gap-4",children:s.map(a=>{if(a.condicional&&!h.evaluateFieldCondition(a.condicional,i,r))return null;const o=a.tamanho??12,c=a.inicioColuna,u=c?`${c} / span ${o}`:`span ${o}`;return n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:u},children:n.jsx(sr,{container:a,control:e})},a.id)})})},Te=x.createContext({submitting:!1,warnings:{},requestSubmit:()=>{}}),tn=Te.Provider,rn=()=>{const t=ar("useFormApi"),e=x.useContext(Te);return{change:(r,s)=>t.setValue(r,s,{shouldValidate:!0,shouldDirty:!0}),reset:r=>t.reset(r),submit:e.requestSubmit,getState:()=>{const{errors:r,isDirty:s,isValid:i}=t.formState;return{values:t.getValues(),errors:Object.fromEntries(Object.entries(r).map(([a,o])=>[a,o==null?void 0:o.message])),warnings:e.warnings,dirty:s,valid:i,submitting:e.submitting}}}},ir=()=>{const t=ar("useFormState"),e=x.useContext(Te),r=I.useWatch({control:t.control}),{errors:s,isDirty:i,isValid:a}=t.formState;return{values:r,errors:Object.fromEntries(Object.entries(s).map(([o,c])=>[o,c==null?void 0:c.message])),warnings:e.warnings,dirty:i,valid:a,submitting:e.submitting}},sn=t=>{var a;const e=I.useFormContext(),{warnings:r}=x.useContext(Te),s=I.useWatch({control:e.control,name:t}),i=e.getFieldState(t,e.formState);return{value:s,error:(a=i.error)==null?void 0:a.message,warning:r[t],dirty:i.isDirty,touched:i.isTouched,valid:!i.error}},nn=t=>{var a;const{control:e}=I.useFormContext(),{warnings:r}=x.useContext(Te),{field:s,fieldState:i}=I.useController({name:t,control:e});return{input:{name:s.name,value:s.value,onChange:s.onChange,onBlur:s.onBlur,ref:s.ref},meta:{error:(a=i.error)==null?void 0:a.message,warning:r[t],touched:i.isTouched,dirty:i.isDirty,valid:!i.error}}},ar=t=>{const e=I.useFormContext();if(!e)throw new Error(`[SchemaForms] O hook '${t}' foi chamado fora de um <FormRenderer />. Certifique-se de que o componente está dentro da árvore de renderização do formulário.`);return e},Pt=({stepIndex:t,totalSteps:e,step:r,defaultValues:s,externalData:i,fieldErrors:a,isSubmitting:o,submitError:c,validatorMapper:u={},onWarningsChange:d,onValuesChange:l,onSubmit:m,onBack:f})=>{const p=t===e-1,g=x.useMemo(()=>JSON.stringify(i),[i]),k=x.useMemo(()=>Lt(r,i,u),[r.id,g]),w=x.useMemo(()=>zt(r,i,u),[r.id,g]),[C,v]=x.useState({}),y=x.useRef(d);y.current=d;const D=i,B=x.useMemo(()=>$t(r,D),[r,g]),E=I.useForm({resolver:k,defaultValues:s,mode:"onTouched"}),{control:j,handleSubmit:b,setError:S,clearErrors:N,setValue:R}=E;x.useEffect(()=>{N();for(const[T,ae]of Object.entries(a))S(T,{type:"server",message:ae})},[a,S,N]);const W=x.useMemo(()=>r.containers.filter(T=>!T.repeatable).flatMap(T=>T.campos).filter(T=>!!T.condicional),[r.containers]),Z=x.useMemo(()=>r.containers.filter(T=>!!T.condicional),[r.containers]),ee=x.useMemo(()=>r.containers.filter(T=>!T.repeatable).flatMap(T=>T.campos).filter(T=>{var ae;return T.condicional&&((ae=T.setValues)==null?void 0:ae.length)}),[r.containers]),te=x.useMemo(()=>r.containers.filter(T=>T.repeatable&&!!T.nome).map(T=>({container:T,fields:T.campos.filter(ae=>!!ae.condicional)})).filter(T=>T.fields.length>0),[r.containers]),_=x.useRef({}),se=x.useRef(!0),ne=I.useWatch({control:j}),P=x.useRef(l);P.current=l,x.useEffect(()=>{var T;(T=P.current)==null||T.call(P,ne)},[ne]),x.useEffect(()=>{let T=!1;return w(ne).then(Y=>{var O;T||(v(Y),(O=y.current)==null||O.call(y,Y))}).catch(Y=>{T||console.error("[StepForm] warnComputer error:",Y)}),()=>{T=!0}},[ne,w]),x.useEffect(()=>{var Y;if(!W.length&&!ee.length&&!Z.length&&!te.length)return;const T=ne;for(const O of W)if(!h.evaluateFieldCondition(O.condicional,T,i)){if(N(O.nome),O.tipo===h.FieldType.FIELD_ARRAY){const L=T[O.nome];Array.isArray(L)&&L.forEach((q,J)=>{(O.subFields??[]).forEach(ue=>N(`${O.nome}.${J}.${ue.nome}`))})}if(O.clearedValue!==void 0){const L=O.clearedValue??"";T[O.nome]!==L&&R(O.nome,L,{shouldValidate:!1})}}for(const O of Z)if(!h.evaluateFieldCondition(O.condicional,T,i))if(O.repeatable&&O.nome)(Array.isArray(T[O.nome])?T[O.nome]:[]).forEach((q,J)=>{for(const ue of O.campos)N(`${O.nome}.${J}.${ue.nome}`)});else for(const L of O.campos){N(L.nome);const q=L.clearedValue!==void 0?L.clearedValue:void 0;q!==void 0&&T[L.nome]!==q&&R(L.nome,q,{shouldValidate:!1})}for(const{container:O,fields:H}of te){const L=O.nome,q=Array.isArray(T[L])?T[L]:[];for(let J=0;J<q.length;J++){const ue=q[J];for(const me of H)if(!h.evaluateFieldCondition(me.condicional,ue,i)&&(N(`${L}.${J}.${me.nome}`),me.clearedValue!==void 0)){const Ee=me.clearedValue??"";ue[me.nome]!==Ee&&R(`${L}.${J}.${me.nome}`,Ee,{shouldValidate:!1})}}}const ae=se.current;for(const O of ee){const H=h.evaluateFieldCondition(O.condicional,T,i),L=ae?H:_.current[O.nome]??!1;if(H&&!L&&((Y=O.setValues)!=null&&Y.length))for(const q of O.setValues){const J=typeof q.valor=="string"?K(q.valor,D):q.valor;R(q.campo,J,{shouldValidate:!1})}_.current[O.nome]=H}se.current=!1},[ne,W,ee,Z,te,i,R,N]);const X=B.icone?Ue[B.icone]:void 0,be=x.useMemo(()=>()=>{E.handleSubmit(m)()},[m]);return n.jsx(I.FormProvider,{...E,children:n.jsx(tn,{value:{submitting:o,warnings:C,requestSubmit:be},children:n.jsx("form",{onSubmit:b(m),noValidate:!0,onKeyDown:T=>{T.key==="Enter"&&T.target.tagName==="INPUT"&&T.preventDefault()},children:n.jsxs("div",{className:"space-y-6",children:[B.showLabel!==!1&&n.jsxs("div",{className:"text-center space-y-2",children:[X&&n.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl flex items-center justify-center",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:n.jsx(X,{className:"w-6 h-6",style:{color:"var(--t-primary)"}})}),n.jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:B.titulo}),B.descricao&&n.jsx("p",{className:"text-sm text-muted-foreground",children:B.descricao})]}),n.jsx(nr,{step:B,control:j,externalData:i}),n.jsxs("div",{className:"flex items-center justify-between gap-4 pt-6 pb-2",children:[n.jsxs(F.Button,{type:"button",variant:"outline",onClick:f,disabled:t===0,className:F.cn(t>0&&"border-primary/40 text-primary hover:bg-primary/5"),children:[n.jsx(A.ChevronLeft,{className:"w-4 h-4"}),n.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),n.jsxs("span",{className:"text-xs font-semibold tabular-nums sm:hidden text-muted-foreground",children:[t+1,"/",e]}),n.jsxs(F.Button,{type:"submit",disabled:o,children:[o?n.jsx(A.Loader2,{className:"w-4 h-4 animate-spin"}):p?n.jsx(A.Check,{className:"w-4 h-4"}):n.jsx(A.ChevronRight,{className:"w-4 h-4"}),n.jsx("span",{className:"hidden sm:inline",children:p?"Finalizar":"Próximo"})]})]}),c&&n.jsx("p",{className:"text-sm text-destructive mt-2 text-center",children:c})]})})})})},$e=t=>{if(t)return Ue[t]},an=({steps:t,currentStep:e,onStepClick:r})=>n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:t.map((s,i)=>n.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(i),onKeyDown:a=>a.key==="Enter"&&(r==null?void 0:r(i)),className:F.cn("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:i===e?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:i<e?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:i<e?n.jsx(A.Check,{className:"w-4 h-4"}):i+1},s.id))}),on=({steps:t,currentStep:e,onStepClick:r})=>n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:t.map((s,i)=>{const a=$e(s.icone)??A.CircleDot;return n.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(i),onKeyDown:o=>o.key==="Enter"&&(r==null?void 0:r(i)),className:F.cn("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:i===e?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:i<e?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:i<e?n.jsx(A.Check,{className:"w-4 h-4"}):n.jsx(a,{className:"w-4 h-4"})},s.id)})}),cn=({steps:t,currentStep:e,position:r,orientation:s="horizontal",onStepClick:i})=>s==="vertical"?n.jsx("div",{className:"flex flex-col gap-0",children:t.map((a,o)=>{const c=$e(a.icone)??A.CircleDot,u=o===e,d=o<e,l=o===t.length-1;return n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center",children:[n.jsx("button",{type:"button",onClick:()=>i==null?void 0:i(o),className:F.cn("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",i&&"cursor-pointer hover:opacity-80"),style:u?{background:"var(--t-primary)",color:"#fff",boxShadow:"0 0 10px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#fff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?n.jsx(A.Check,{className:"w-3.5 h-3.5"}):n.jsx(c,{className:"w-3.5 h-3.5"})}),!l&&n.jsx("div",{className:"w-[2px] my-1",style:{height:"24px",background:d?"#22c55e":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]}),n.jsx("span",{className:"text-sm font-medium leading-tight mt-1.5",style:u?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:a.label??a.id})]},a.id)})}):n.jsx("div",{className:"w-full flex items-start",children:t.map((a,o)=>{const c=$e(a.icone)??A.CircleDot,u=o===e,d=o<e,l=o===t.length-1;return n.jsxs("div",{className:F.cn("flex items-start",!l&&"flex-1"),children:[n.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-[56px] shrink-0 mx-auto",children:[n.jsx("button",{type:"button",onClick:()=>i==null?void 0:i(o),className:F.cn("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",i&&"cursor-pointer hover:opacity-80"),style:u?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 12px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#ffffff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?n.jsx(A.Check,{className:"w-4 h-4"}):n.jsx(c,{className:"w-4 h-4"})}),n.jsx("span",{className:"text-[10px] font-medium text-center leading-tight line-clamp-2 px-0.5",style:u?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:a.label??a.id})]}),!l&&n.jsx("div",{className:"flex-1 h-[1.5px] mt-5 mx-1",style:{background:d?"linear-gradient(90deg, var(--t-primary), color-mix(in srgb, var(--t-primary) 40%, transparent))":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]},a.id)})}),or=({steps:t,currentStep:e,onStepClick:r,className:s,forceShow:i})=>{const a=ke.useTemplate(),{layout:o}=a;if(!o.showStepIndicators||t.length<=1&&!i)return null;const c=o.stepIndicatorVariant??"numbers",u=o.stepIndicatorPosition??"top-center",d=o.stepIndicatorOrientation??"horizontal",l=(e+1)/t.length*100,m=t[e],f=$e(m==null?void 0:m.icone)??A.CircleDot,p=n.jsx("div",{className:"h-1 rounded-full overflow-hidden",style:{background:"color-mix(in srgb, var(--t-primary) 15%, transparent)"},children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${l}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),g=n.jsxs("div",{className:"block sm:hidden space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:"var(--t-primary)",color:"#fff"},children:n.jsx(f,{className:"w-5 h-5"})}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-sm font-semibold leading-tight truncate",style:{color:"var(--t-text)"},children:(m==null?void 0:m.label)??(m==null?void 0:m.id)}),n.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",e+1," de ",t.length]})]})]}),p]}),k=n.jsxs("div",{className:"hidden sm:block",children:[c==="numbers"&&n.jsx(an,{steps:t,currentStep:e,onStepClick:r}),c==="icons"&&n.jsx(on,{steps:t,currentStep:e,onStepClick:r}),c==="icons-labeled"&&n.jsx(cn,{steps:t,currentStep:e,position:u,orientation:d,onStepClick:r})]}),w=o.showProgressBar?n.jsx("div",{className:"hidden sm:block",children:p}):null;return d==="vertical"?n.jsxs("div",{className:F.cn("flex gap-6 items-start",s),children:[g,n.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[k,w&&n.jsx("div",{className:"flex-1 pt-4",children:w})]})]}):n.jsxs("div",{className:F.cn("space-y-3",s),children:[g,n.jsxs("div",{className:"hidden sm:block space-y-3",children:[k,w]})]})},ln=(t,e,r)=>{var a;const s={...e},i=r;for(const o of t.containers){for(const c of o.campos)if(s[c.nome]===void 0&&(c.initialValue!==void 0?s[c.nome]=typeof c.initialValue=="string"?K(c.initialValue,i):c.initialValue:c.defaultValue!==void 0&&(s[c.nome]=c.defaultValue)),c.tipo===h.FieldType.FIELD_ARRAY&&((a=c.subFields)!=null&&a.length)){const u=s[c.nome];Array.isArray(u)&&u.length>0&&(s[c.nome]=u.map(d=>{const l={...d};for(const m of c.subFields)l[m.nome]===void 0&&(m.initialValue!==void 0?l[m.nome]=typeof m.initialValue=="string"?K(m.initialValue,i):m.initialValue:m.defaultValue!==void 0&&(l[m.nome]=m.defaultValue));return l}))}if(o.repeatable&&o.nome){const c=s[o.nome];Array.isArray(c)&&c.length>0&&(s[o.nome]=c.map(u=>{const d={...u};for(const l of o.campos)d[l.nome]===void 0&&(l.initialValue!==void 0?d[l.nome]=typeof l.initialValue=="string"?K(l.initialValue,i):l.initialValue:l.defaultValue!==void 0&&(d[l.nome]=l.defaultValue));return d}))}}return s},dn=({schema:t,initialValues:e={},initialStep:r=0,onSubmitStep:s,onComplete:i,template:a,formTitle:o,externalData:c={},fieldErrors:u={},uploadFile:d,deleteUploadedFile:l,cepLookup:m,resolveTermsUploadUrl:f,fieldResolvers:p,validatorMapper:g,componentMapper:k,paymentMethodOptions:w,onValuesChange:C,className:v,StepIndicator:y=or})=>{const[D,B]=x.useState(()=>r),[E,j]=x.useState({...e}),[b,S]=x.useState(()=>r),[N,R]=x.useState(!1),[W,Z]=x.useState(null),[ee,te]=x.useState({}),_=x.useRef(f);_.current=f;const se=x.useCallback(z=>_.current(z),[]),ne=!!f,P=x.useRef(l);P.current=l;const X=x.useCallback(z=>P.current(z),[]),be=!!l,T=x.useMemo(()=>JSON.stringify(c),[c]),ae=x.useMemo(()=>JSON.stringify(t.stepConfig),[t.stepConfig]),Y=x.useMemo(()=>{const z=ke.getTemplateConfig(a);return t.stepConfig?{...z,layout:{...z.layout,...t.stepConfig}}:z},[a,ae]),O=x.useMemo(()=>[...t.steps].sort((z,pe)=>z.ordem-pe.ordem),[t.steps]),H=O.length,L=H>0?O[Math.min(D,H-1)]:null,q=x.useMemo(()=>L?ln(L,E,c):{},[L,E,T]),J=x.useMemo(()=>({uploadFile:d,deleteUploadedFile:be?X:void 0,cepLookup:m,resolveTermsUploadUrl:ne?se:void 0,externalData:c,fieldResolvers:p,validatorMapper:g,fieldWarnings:ee,componentMapper:k,paymentMethodOptions:w}),[d,be,X,m,se,ne,p,g,ee,k,w,T]),ue=x.useCallback(async z=>{if(!N){R(!0),Z(null);try{const{cleaned:pe,fileIdsToDelete:Ie}=h.stripHiddenFields(L,z,c);Ie.length&&l&&await Promise.allSettled(Ie.map(Be=>l(Be)));const dt={...E,...pe};if(j(dt),s&&await s(D,pe),D===H-1)i&&await i(dt);else{const Be=D+1;B(Be),S(cr=>Math.max(cr,Be))}}catch(pe){console.error("[FormRenderer] Submit error:",pe);const Ie=pe instanceof Error?pe.message:"Ocorreu um erro. Tente novamente.";Z(Ie)}finally{R(!1)}}},[D,E,N,H,s,i,L,c,l]),me=x.useCallback(()=>{D>0&&B(z=>z-1)},[D]);if(!L)return n.jsx(ze.Provider,{value:J,children:n.jsx(ke.TemplateProvider,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:n.jsx("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6 text-center text-muted-foreground",children:"Nenhum step configurado."})})});const Ge=Y.layout.eventTitleStyle??"bar",Ee=(Y.layout.stepIndicatorOrientation??"horizontal")==="vertical",Ae=H>=1?n.jsx(y,{steps:O.map(z=>({id:z.id,label:z.titulo,icone:z.icone})),currentStep:D,onStepClick:z=>{z!==D&&z<=b&&B(z)}}):null;return n.jsx(ze.Provider,{value:J,children:n.jsx(ke.TemplateProvider,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:n.jsxs("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6",children:[o&&Ge==="bar"&&n.jsx("div",{className:"w-full text-center text-sm font-medium py-2.5 px-4 mb-6 rounded-lg border border-input text-muted-foreground bg-muted/30",children:o}),o&&Ge==="inline"&&n.jsxs("div",{className:"text-center mb-6",children:[n.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-1",style:{color:"var(--t-text-muted)"},children:"Inscrição"}),n.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:o}),n.jsx("div",{className:"h-0.5 w-12 mx-auto mt-3 rounded-full",style:{background:"var(--t-primary)"}})]}),Ee?n.jsxs("div",{className:"flex gap-6 items-start",children:[n.jsx("div",{className:"hidden sm:block shrink-0 w-44 pt-1",children:Ae}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"sm:hidden mb-6",children:Ae}),n.jsx(Pt,{stepIndex:D,totalSteps:H,step:L,defaultValues:q,externalData:c,fieldErrors:u,isSubmitting:N,submitError:W,validatorMapper:g,onWarningsChange:te,onValuesChange:C,onSubmit:ue,onBack:me},D)]})]}):n.jsxs(n.Fragment,{children:[Ae&&n.jsx("div",{className:"mb-8",children:Ae}),n.jsx(Pt,{stepIndex:D,totalSteps:H,step:L,defaultValues:q,externalData:c,fieldErrors:u,isSubmitting:N,submitError:W,validatorMapper:g,onWarningsChange:te,onValuesChange:C,onSubmit:ue,onBack:me},D)]})]})})})},un=({children:t,render:e,onChange:r})=>{const s=ir(),i=x.useRef(r);return i.current=r,x.useEffect(()=>{var a;(a=i.current)==null||a.call(i,s)},[s.values,s.dirty,s.valid,s.submitting,s.errors,s.warnings]),e?n.jsx(n.Fragment,{children:e(s)}):typeof t=="function"?n.jsx(n.Fragment,{children:t(s)}):t!==void 0?n.jsx(n.Fragment,{children:t}):null};Object.defineProperty(exports,"evaluateFieldCondition",{enumerable:!0,get:()=>h.evaluateFieldCondition});exports.ContainerRenderer=sr;exports.DFCepField=lt;exports.DFCheckbox=qe;exports.DFCheckboxGroup=rt;exports.DFDateField=je;exports.DFFieldArray=Gt;exports.DFFileUpload=ct;exports.DFHidden=He;exports.DFMaskedInput=ge;exports.DFParticipationType=Kt;exports.DFPaymentMethod=Jt;exports.DFRadioGroup=st;exports.DFSelect=We;exports.DFTerms=Qt;exports.DFTextField=re;exports.DFTextarea=_e;exports.DefaultStepIndicator=or;exports.FormRenderer=dn;exports.FormSpy=un;exports.OPCOES_POR_DIA=Xt;exports.OPCOES_TODOS_OS_DIAS=Yt;exports.RendererContext=ze;exports.StepRenderer=nr;exports.interpolate=K;exports.interpolateContainer=Ve;exports.interpolateField=Mt;exports.interpolateStep=$t;exports.makeStepResolver=Lt;exports.makeStepWarnComputer=zt;exports.useField=sn;exports.useFieldApi=nn;exports.useFormApi=rn;exports.useFormState=ir;exports.useRendererContext=xe;
1
+ "use strict";var fr=Object.defineProperty;var pr=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Xe=(t,e,r)=>pr(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),f=require("react"),Se=require("@schema-forms-data/templates"),R=require("react-hook-form"),A=require("lucide-react"),w=require("@schema-forms-data/ui"),h=require("@schema-forms-data/core");function hr(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const _e=hr(A),Me=f.createContext({}),pe=()=>f.useContext(Me),pt=new Set(["__proto__","constructor","prototype"]),Oe=(t,e,r)=>{const s=e.split(".");let i=t;for(let o=0;o<s.length-1;o++){const c=s[o];if(pt.has(c))return;(i[c]==null||typeof i[c]!="object")&&(i[c]={}),i=i[c]}const a=s[s.length-1];pt.has(a)||(i[a]=r)},Ce=async(t,e,r,s,i,a)=>{for(const o of t){const c=a[o.type];if(!c)continue;const u=await c(r,s,o,i);if(u)return o.message??u}},Ut=(t,e={},r={})=>async s=>{var u,d,l,m,x;const i={},{errors:a}=h.validateStepData(t,s,e);for(const p of a){const b=p.campo.replace(/\[(\d+)\]/g,".$1");Oe(i,b,{type:"custom",message:p.message})}const o=[...t.containers].sort((p,b)=>p.ordem-b.ordem);for(const p of o)if(!p.repeatable&&h.evaluateFieldCondition(p.condicional,s,e))for(const b of p.campos){if(b.tipo===h.FieldType.HIDDEN||b.isDisabled||b.isReadOnly||!h.evaluateFieldCondition(b.condicional,s,e))continue;if(b.tipo===h.FieldType.FIELD_ARRAY){const C=Array.isArray(s[b.nome])?s[b.nome]:[];for(let v=0;v<C.length;v++){const y=C[v];for(const g of b.subFields??[]){if(g.isDisabled||g.isReadOnly||!h.evaluateFieldCondition(g.condicional,y,e)||!((u=g.validate)!=null&&u.length)||i[`${b.nome}.${v}.${g.nome}`])continue;const j=await Ce(g.validate,g.nome,y[g.nome],y,e,r);j&&Oe(i,`${b.nome}.${v}.${g.nome}`,{type:"custom",message:j})}}continue}if(b.tipo===h.FieldType.SUB_FORM){const C=s[b.nome]??{};for(const v of((d=b.subSchema)==null?void 0:d.fields)??[]){if(v.isDisabled||v.isReadOnly||!((l=v.validate)!=null&&l.length)||i[`${b.nome}.${v.nome}`])continue;const y=await Ce(v.validate,v.nome,C[v.nome],C,e,r);y&&Oe(i,`${b.nome}.${v.nome}`,{type:"custom",message:y})}continue}if(!((m=b.validate)!=null&&m.length)||i[b.nome])continue;const F=await Ce(b.validate,b.nome,s[b.nome],s,e,r);F&&(i[b.nome]={type:"custom",message:F})}for(const p of o){if(!p.repeatable||!p.nome||!h.evaluateFieldCondition(p.condicional,s,e))continue;const b=Array.isArray(s[p.nome])?s[p.nome]:[];for(let F=0;F<b.length;F++){const C=b[F];for(const v of p.campos){if(v.tipo===h.FieldType.HIDDEN||v.isDisabled||v.isReadOnly||!h.evaluateFieldCondition(v.condicional,C,e)||!((x=v.validate)!=null&&x.length)||i[`${p.nome}.${F}.${v.nome}`])continue;const y=await Ce(v.validate,v.nome,C[v.nome],C,e,r);y&&Oe(i,`${p.nome}.${F}.${v.nome}`,{type:"custom",message:y})}}}return Object.keys(i).length>0?{values:{},errors:i}:{values:s,errors:{}}},_t=(t,e={},r={})=>async s=>{var o,c;const i={},a=[...t.containers].sort((u,d)=>u.ordem-d.ordem);for(const u of a)if(!(u.condicional&&!h.evaluateFieldCondition(u.condicional,s,e))){if(u.repeatable&&u.nome){const d=Array.isArray(s[u.nome])?s[u.nome]:[];for(let l=0;l<d.length;l++){const m=d[l];for(const x of[...u.campos].sort((p,b)=>p.ordem-b.ordem)){if(!((o=x.warn)!=null&&o.length)||!h.evaluateFieldCondition(x.condicional,m,e))continue;const b=await Ce(x.warn,x.nome,m[x.nome],m,e,r);b&&(i[`${u.nome}.${l}.${x.nome}`]=b)}}continue}for(const d of[...u.campos].sort((l,m)=>l.ordem-m.ordem)){if(!((c=d.warn)!=null&&c.length)||!h.evaluateFieldCondition(d.condicional,s,e))continue;const m=await Ce(d.warn,d.nome,s[d.nome],s,e,r);m&&(i[d.nome]=m)}}return i},gr=/\{\{\s*(?:event|evento)\.([a-zA-Z0-9_.]+)\s*\}\}/g,Q=(t,e)=>t?t.replace(gr,(r,s)=>e[`evento.${s}`]??e[s]??r):t??"",br=(t,e)=>({...t,label:Q(t.label,e)}),Vt=(t,e)=>{var r;return{...t,label:Q(t.label,e),placeholder:Q(t.placeholder,e),hint:Q(t.hint,e),defaultValue:typeof t.defaultValue=="string"?Q(t.defaultValue,e):t.defaultValue,opcoes:(r=t.opcoes)==null?void 0:r.map(s=>br(s,e))}},Ve=(t,e)=>({...t,titulo:Q(t.titulo,e),descricao:Q(t.descricao,e),campos:t.campos.map(r=>Vt(r,e))}),Wt=(t,e)=>({...t,titulo:Q(t.titulo,e),descricao:Q(t.descricao,e),containers:t.containers.map(r=>Ve(r,e))}),qt=()=>{const t=Se.useTemplate(),e=t.layout.containerStyle,r=t.layout.roundness??"rounded-xl",s=w.cn("overflow-hidden",r,e==="card"?"border":"",e==="bordered"?"border":"",e==="glassmorphism"?"backdrop-blur-sm":""),i=e==="glassmorphism"?{background:"var(--t-surface)",borderColor:"var(--t-border)",borderWidth:"1px",borderStyle:"solid"}:{},a=w.cn("border-b px-6 py-4",e==="flat"?"border-transparent":"");return{wrapperClass:s,wrapperStyle:i,headerClass:a,headerStyle:e==="glassmorphism"?{borderColor:"var(--t-border)"}:{},tmpl:t}},ne=({name:t,control:e,placeholder:r,type:s="text",disabled:i,readOnly:a})=>{var d;const{field:o,fieldState:c}=R.useController({name:t,control:e}),u=!!c.error;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(w.Input,{...o,value:o.value??"",type:s,placeholder:r,disabled:i,readOnly:a,className:w.cn(u&&"border-destructive focus-visible:ring-destructive")}),((d=c.error)==null?void 0:d.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},We=({name:t,control:e,placeholder:r,disabled:s,readOnly:i})=>{var c;const{field:a,fieldState:o}=R.useController({name:t,control:e});return n.jsxs("div",{className:"space-y-1",children:[n.jsx(w.Textarea,{...a,value:a.value??"",placeholder:r,disabled:s,readOnly:i,rows:3,className:w.cn(o.error&&"border-destructive focus-visible:ring-destructive")}),((c=o.error)==null?void 0:c.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},qe=({name:t,control:e,placeholder:r,options:s,disabled:i,readOnly:a})=>{var u;const{field:o,fieldState:c}=R.useController({name:t,control:e});return n.jsxs("div",{className:"space-y-1",children:[n.jsxs(w.Select,{value:o.value??"",onValueChange:d=>!a&&o.onChange(d),disabled:i||a,children:[n.jsx(w.SelectTrigger,{className:w.cn(c.error&&"border-destructive focus:ring-destructive"),onBlur:o.onBlur,children:n.jsx(w.SelectValue,{placeholder:r??"Selecione..."})}),n.jsx(w.SelectContent,{children:s.map(d=>n.jsx(w.SelectItem,{value:d.valor,disabled:d.disabled,children:d.label},d.valor))})]}),((u=c.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Ze=({name:t,control:e,label:r,disabled:s,readOnly:i})=>{var c;const{field:a,fieldState:o}=R.useController({name:t,control:e});return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx(w.Checkbox,{name:a.name,checked:!!a.value,onCheckedChange:u=>!i&&a.onChange(!!u),onBlur:a.onBlur,disabled:s}),r&&n.jsx("span",{className:"text-sm leading-none",children:r})]}),((c=o.error)==null?void 0:c.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},st=({name:t,control:e,options:r,disabled:s})=>{var u;const{field:i,fieldState:a}=R.useController({name:t,control:e}),o=Array.isArray(i.value)?i.value:[],c=d=>{const l=o.includes(d)?o.filter(m=>m!==d):[...o,d];i.onChange(l)};return n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"flex flex-col gap-2",onBlur:i.onBlur,children:r.map(d=>n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx(w.Checkbox,{checked:o.includes(d.valor),onCheckedChange:()=>c(d.valor),disabled:s||d.disabled}),n.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((u=a.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:a.error.message})]})},nt=({name:t,control:e,options:r,visualStyle:s="default",disabled:i})=>{var u;const{field:a,fieldState:o}=R.useController({name:t,control:e}),c=s==="card";return n.jsxs("div",{className:"space-y-1",onBlur:a.onBlur,children:[n.jsx(w.RadioGroup,{value:a.value??"",onValueChange:a.onChange,className:w.cn(c?"grid grid-cols-2 gap-2 sm:grid-cols-3":"flex flex-col gap-2"),children:r.map(d=>n.jsxs("label",{className:w.cn("flex items-center gap-2 cursor-pointer",c&&"rounded-lg border p-3 transition-colors hover:bg-accent data-[selected=true]:border-primary data-[selected=true]:bg-primary/5",(i||d.disabled)&&"cursor-not-allowed opacity-50"),"data-selected":a.value===d.valor?"true":void 0,children:[n.jsx(w.RadioGroupItem,{value:d.valor,disabled:i||d.disabled}),n.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((u=o.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},Zt=t=>{const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${s}`},yr=t=>{const e=new Date;return e.setFullYear(e.getFullYear()-t),Zt(e)},vr=t=>{const e=new Date;return e.setFullYear(e.getFullYear()-t),Zt(e)},Fe=({name:t,control:e,isDatetime:r,disabled:s,readOnly:i,validacao:a})=>{var x;const{field:o,fieldState:c}=R.useController({name:t,control:e}),u=r?"datetime-local":"date",d=p=>r?p+"T00:00":p,l=(a==null?void 0:a.minAge)!=null?d(yr(a.minAge)):(a==null?void 0:a.maxDate)!=null?d(a.maxDate):void 0,m=(a==null?void 0:a.maxAge)!=null?d(vr(a.maxAge)):(a==null?void 0:a.minDate)!=null?d(a.minDate):void 0;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(w.Input,{name:o.name,value:o.value??"",onChange:o.onChange,onBlur:o.onBlur,type:u,min:m,max:l,disabled:s,readOnly:i,className:w.cn(c.error&&"border-destructive focus-visible:ring-destructive")}),((x=c.error)==null?void 0:x.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})};function wr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const Ht={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};for(const[t,e]of Object.entries(Ht));let Pe;function Cr(){if(!(typeof globalThis.TextDecoder>"u"))return Pe??(Pe=new globalThis.TextDecoder("utf-8"))}const ke=32*1024,ce=65533;function jr(t,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{const r=Cr();return r?r.decode(t):kr(t)}case"utf-16le":return Nr(t);case"us-ascii":case"ascii":return Sr(t);case"latin1":case"iso-8859-1":return Dr(t);case"windows-1252":return Tr(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function it(t,e){e.length!==0&&(t.push(String.fromCharCode.apply(null,e)),e.length=0)}function H(t,e,r){e.push(r),e.length>=ke&&it(t,e)}function Fr(t,e,r){if(r<=65535){H(t,e,r);return}r-=65536,H(t,e,55296+(r>>10)),H(t,e,56320+(r&1023))}function kr(t){const e=[],r=[];let s=0;for(t.length>=3&&t[0]===239&&t[1]===187&&t[2]===191&&(s=3);s<t.length;){const i=t[s];if(i<=127){H(e,r,i),s++;continue}if(i<194||i>244){H(e,r,ce),s++;continue}if(i<=223){if(s+1>=t.length){H(e,r,ce),s++;continue}const l=t[s+1];if((l&192)!==128){H(e,r,ce),s++;continue}const m=(i&31)<<6|l&63;H(e,r,m),s+=2;continue}if(i<=239){if(s+2>=t.length){H(e,r,ce),s++;continue}const l=t[s+1],m=t[s+2];if(!((l&192)===128&&(m&192)===128&&!(i===224&&l<160)&&!(i===237&&l>=160))){H(e,r,ce),s++;continue}const p=(i&15)<<12|(l&63)<<6|m&63;H(e,r,p),s+=3;continue}if(s+3>=t.length){H(e,r,ce),s++;continue}const a=t[s+1],o=t[s+2],c=t[s+3];if(!((a&192)===128&&(o&192)===128&&(c&192)===128&&!(i===240&&a<144)&&!(i===244&&a>143))){H(e,r,ce),s++;continue}const d=(i&7)<<18|(a&63)<<12|(o&63)<<6|c&63;Fr(e,r,d),s+=4}return it(e,r),e.join("")}function Nr(t){const e=[],r=[],s=t.length;let i=0;for(;i+1<s;){const a=t[i]|t[i+1]<<8;if(i+=2,a>=55296&&a<=56319){if(i+1<s){const o=t[i]|t[i+1]<<8;o>=56320&&o<=57343?(H(e,r,a),H(e,r,o),i+=2):H(e,r,ce)}else H(e,r,ce);continue}if(a>=56320&&a<=57343){H(e,r,ce);continue}H(e,r,a)}return i<s&&H(e,r,ce),it(e,r),e.join("")}function Sr(t){const e=[];for(let r=0;r<t.length;r+=ke){const s=Math.min(t.length,r+ke),i=new Array(s-r);for(let a=r,o=0;a<s;a++,o++)i[o]=t[a]&127;e.push(String.fromCharCode.apply(null,i))}return e.join("")}function Dr(t){const e=[];for(let r=0;r<t.length;r+=ke){const s=Math.min(t.length,r+ke),i=new Array(s-r);for(let a=r,o=0;a<s;a++,o++)i[o]=t[a];e.push(String.fromCharCode.apply(null,i))}return e.join("")}function Tr(t){const e=[];let r="";for(let s=0;s<t.length;s++){const i=t[s],a=i>=128&&i<=159?Ht[i]:void 0;r+=a??String.fromCharCode(i),r.length>=ke&&(e.push(r),r="")}return r&&e.push(r),e.join("")}function re(t){return new DataView(t.buffer,t.byteOffset)}const Er={len:1,get(t,e){return re(t).getUint8(e)},put(t,e,r){return re(t).setUint8(e,r),e+1}},W={len:2,get(t,e){return re(t).getUint16(e,!0)},put(t,e,r){return re(t).setUint16(e,r,!0),e+2}},we={len:2,get(t,e){return re(t).getUint16(e)},put(t,e,r){return re(t).setUint16(e,r),e+2}},q={len:4,get(t,e){return re(t).getUint32(e,!0)},put(t,e,r){return re(t).setUint32(e,r,!0),e+4}},ht={len:4,get(t,e){return re(t).getUint32(e)},put(t,e,r){return re(t).setUint32(e,r),e+4}},Ar={len:4,get(t,e){return re(t).getInt32(e)},put(t,e,r){return re(t).setInt32(e,r),e+4}},Ir={len:8,get(t,e){return re(t).getBigUint64(e,!0)},put(t,e,r){return re(t).setBigUint64(e,r,!0),e+8}};class fe{constructor(e,r){this.len=e,this.encoding=r}get(e,r=0){const s=e.subarray(r,r+this.len);return jr(s,this.encoding)}}const Br="End-Of-Stream";class G extends Error{constructor(){super(Br),this.name="EndOfStreamError"}}class Rr extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}class Gt{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,r=!1){const s=await this.read(e,r);return this.peekQueue.push(e.subarray(0,s)),s}async read(e,r=!1){if(e.length===0)return 0;let s=this.readFromPeekBuffer(e);if(this.endOfStream||(s+=await this.readRemainderFromStream(e.subarray(s),r)),s===0&&!r)throw new G;return s}readFromPeekBuffer(e){let r=e.length,s=0;for(;this.peekQueue.length>0&&r>0;){const i=this.peekQueue.pop();if(!i)throw new Error("peekData should be defined");const a=Math.min(i.length,r);e.set(i.subarray(0,a),s),s+=a,r-=a,a<i.length&&this.peekQueue.push(i.subarray(a))}return s}async readRemainderFromStream(e,r){let s=0;for(;s<e.length&&!this.endOfStream;){if(this.interrupted)throw new Rr;const i=await this.readFromStream(e.subarray(s),r);if(i===0)break;s+=i}if(!r&&s<e.length)throw new G;return s}}class Or extends Gt{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class Pr extends Or{async readFromStream(e,r){if(e.length===0)return 0;const s=await this.reader.read(new Uint8Array(e.length),{min:r?void 0:e.length});return s.done&&(this.endOfStream=s.done),s.value?(e.set(s.value),s.value.length):0}}class gt extends Gt{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,r){const s=Math.min(r.length,e.length);return e.set(r.subarray(0,s)),s<r.length?this.buffer=r.subarray(s):this.buffer=null,s}async readFromStream(e,r){if(e.length===0)return 0;let s=0;for(this.buffer&&(s+=this.writeChunk(e,this.buffer));s<e.length&&!this.endOfStream;){const i=await this.reader.read();if(i.done){this.endOfStream=!0;break}i.value&&(s+=this.writeChunk(e.subarray(s),i.value))}if(!r&&s===0&&this.endOfStream)throw new G;return s}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}function Lr(t){try{const e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new gt(e):new Pr(e)}catch(e){if(e instanceof TypeError)return new gt(t.getReader());throw e}}class at{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e==null?void 0:e.onClose,e!=null&&e.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,r=this.position){const s=new Uint8Array(e.len);if(await this.readBuffer(s,{position:r})<e.len)throw new G;return e.get(s,0)}async peekToken(e,r=this.position){const s=new Uint8Array(e.len);if(await this.peekBuffer(s,{position:r})<e.len)throw new G;return e.get(s,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new G;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new G;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw new RangeError("ignore length must be ≥ 0 bytes");if(this.fileInfo.size!==void 0){const r=this.fileInfo.size-this.position;if(e>r)return this.position+=r,r}return this.position+=e,e}async close(){var e;await this.abort(),await((e=this.onClose)==null?void 0:e.call(this))}normalizeOptions(e,r){if(!this.supportsRandomAccess()&&r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...r}}abort(){return Promise.resolve()}}const zr=256e3;class Mr extends at{constructor(e,r){super(r),this.streamReader=e,this.fileInfo=(r==null?void 0:r.fileInfo)??{}}async readBuffer(e,r){const s=this.normalizeOptions(e,r),i=s.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(e,r);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(s.length===0)return 0;const a=await this.streamReader.read(e.subarray(0,s.length),s.mayBeLess);if(this.position+=a,(!r||!r.mayBeLess)&&a<s.length)throw new G;return a}async peekBuffer(e,r){const s=this.normalizeOptions(e,r);let i=0;if(s.position){const a=s.position-this.position;if(a>0){const o=new Uint8Array(s.length+a);return i=await this.peekBuffer(o,{mayBeLess:s.mayBeLess}),e.set(o.subarray(a)),i-a}if(a<0)throw new Error("Cannot peek from a negative offset in a stream")}if(s.length>0){try{i=await this.streamReader.peek(e.subarray(0,s.length),s.mayBeLess)}catch(a){if(r!=null&&r.mayBeLess&&a instanceof G)return 0;throw a}if(!s.mayBeLess&&i<s.length)throw new G}return i}async ignore(e){if(e<0)throw new RangeError("ignore length must be ≥ 0 bytes");const r=Math.min(zr,e),s=new Uint8Array(r);let i=0;for(;i<e;){const a=e-i,o=await this.readBuffer(s,{length:Math.min(r,a)});if(o<0)return o;i+=o}return i}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class $r extends at{constructor(e,r){super(r),this.uint8Array=e,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:e.length}}async readBuffer(e,r){r!=null&&r.position&&(this.position=r.position);const s=await this.peekBuffer(e,r);return this.position+=s,s}async peekBuffer(e,r){const s=this.normalizeOptions(e,r),i=Math.min(this.uint8Array.length-s.position,s.length);if(!s.mayBeLess&&i<s.length)throw new G;return e.set(this.uint8Array.subarray(s.position,s.position+i)),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}class Ur extends at{constructor(e,r){super(r),this.blob=e,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:e.size,mimeType:e.type}}async readBuffer(e,r){r!=null&&r.position&&(this.position=r.position);const s=await this.peekBuffer(e,r);return this.position+=s,s}async peekBuffer(e,r){const s=this.normalizeOptions(e,r),i=Math.min(this.blob.size-s.position,s.length);if(!s.mayBeLess&&i<s.length)throw new G;const a=await this.blob.slice(s.position,s.position+i).arrayBuffer();return e.set(new Uint8Array(a)),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}function _r(t,e){const r=Lr(t),s=e??{},i=s.onClose;return s.onClose=async()=>{if(await r.close(),i)return i()},new Mr(r,s)}function Vr(t,e){return new $r(t,e)}function Wr(t,e){return new Ur(t,e)}var rt={exports:{}},Ye,bt;function qr(){if(bt)return Ye;bt=1;var t=1e3,e=t*60,r=e*60,s=r*24,i=s*7,a=s*365.25;Ye=function(l,m){m=m||{};var x=typeof l;if(x==="string"&&l.length>0)return o(l);if(x==="number"&&isFinite(l))return m.long?u(l):c(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function o(l){if(l=String(l),!(l.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(m){var x=parseFloat(m[1]),p=(m[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return x*a;case"weeks":case"week":case"w":return x*i;case"days":case"day":case"d":return x*s;case"hours":case"hour":case"hrs":case"hr":case"h":return x*r;case"minutes":case"minute":case"mins":case"min":case"m":return x*e;case"seconds":case"second":case"secs":case"sec":case"s":return x*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return x;default:return}}}}function c(l){var m=Math.abs(l);return m>=s?Math.round(l/s)+"d":m>=r?Math.round(l/r)+"h":m>=e?Math.round(l/e)+"m":m>=t?Math.round(l/t)+"s":l+"ms"}function u(l){var m=Math.abs(l);return m>=s?d(l,m,s,"day"):m>=r?d(l,m,r,"hour"):m>=e?d(l,m,e,"minute"):m>=t?d(l,m,t,"second"):l+" ms"}function d(l,m,x,p){var b=m>=x*1.5;return Math.round(l/x)+" "+p+(b?"s":"")}return Ye}function Zr(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=i,r.enabled=c,r.humanize=qr(),r.destroy=d,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function e(l){let m=0;for(let x=0;x<l.length;x++)m=(m<<5)-m+l.charCodeAt(x),m|=0;return r.colors[Math.abs(m)%r.colors.length]}r.selectColor=e;function r(l){let m,x=null,p,b;function F(...C){if(!F.enabled)return;const v=F,y=Number(new Date),g=y-(m||y);v.diff=g,v.prev=m,v.curr=y,m=y,C[0]=r.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let j=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(T,B)=>{if(T==="%%")return"%";j++;const k=r.formatters[B];if(typeof k=="function"){const D=C[j];T=k.call(v,D),C.splice(j,1),j--}return T}),r.formatArgs.call(v,C),(v.log||r.log).apply(v,C)}return F.namespace=l,F.useColors=r.useColors(),F.color=r.selectColor(l),F.extend=s,F.destroy=r.destroy,Object.defineProperty(F,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(p!==r.namespaces&&(p=r.namespaces,b=r.enabled(l)),b),set:C=>{x=C}}),typeof r.init=="function"&&r.init(F),F}function s(l,m){const x=r(this.namespace+(typeof m>"u"?":":m)+l);return x.log=this.log,x}function i(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];const m=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const x of m)x[0]==="-"?r.skips.push(x.slice(1)):r.names.push(x)}function a(l,m){let x=0,p=0,b=-1,F=0;for(;x<l.length;)if(p<m.length&&(m[p]===l[x]||m[p]==="*"))m[p]==="*"?(b=p,F=x,p++):(x++,p++);else if(b!==-1)p=b+1,F++,x=F;else return!1;for(;p<m.length&&m[p]==="*";)p++;return p===m.length}function o(){const l=[...r.names,...r.skips.map(m=>"-"+m)].join(",");return r.enable(""),l}function c(l){for(const m of r.skips)if(a(l,m))return!1;for(const m of r.names)if(a(l,m))return!0;return!1}function u(l){return l instanceof Error?l.stack||l.message:l}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var Hr=Zr;(function(t,e){e.formatArgs=s,e.save=i,e.load=a,e.useColors=r,e.storage=o(),e.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function s(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;u.splice(1,0,d,"color: inherit");let l=0,m=0;u[0].replace(/%[a-zA-Z%]/g,x=>{x!=="%%"&&(l++,x==="%c"&&(m=l))}),u.splice(m,0,d)}e.log=console.debug||console.log||(()=>{});function i(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch{}}function a(){let u;try{u=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!u&&typeof process<"u"&&"env"in process&&(u=process.env.DEBUG),u}function o(){try{return localStorage}catch{}}t.exports=Hr(e);const{formatters:c}=t.exports;c.j=function(u){try{return JSON.stringify(u)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(rt,rt.exports);var Gr=rt.exports;const Kr=wr(Gr),je={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},yt={get(t){return{signature:q.get(t,0),compressedSize:q.get(t,8),uncompressedSize:q.get(t,12)}},len:16},Xr={get(t){const e=W.get(t,6);return{signature:q.get(t,0),minVersion:W.get(t,4),dataDescriptor:!!(e&8),compressedMethod:W.get(t,8),compressedSize:q.get(t,18),uncompressedSize:q.get(t,22),filenameLength:W.get(t,26),extraFieldLength:W.get(t,28),filename:null}},len:30},Yr={get(t){return{signature:q.get(t,0),nrOfThisDisk:W.get(t,4),nrOfThisDiskWithTheStart:W.get(t,6),nrOfEntriesOnThisDisk:W.get(t,8),nrOfEntriesOfSize:W.get(t,10),sizeOfCd:q.get(t,12),offsetOfStartOfCd:q.get(t,16),zipFileCommentLength:W.get(t,20)}},len:22},Jr={get(t){const e=W.get(t,8);return{signature:q.get(t,0),minVersion:W.get(t,6),dataDescriptor:!!(e&8),compressedMethod:W.get(t,10),compressedSize:q.get(t,20),uncompressedSize:q.get(t,24),filenameLength:W.get(t,28),extraFieldLength:W.get(t,30),fileCommentLength:W.get(t,32),relativeOffsetOfLocalHeader:q.get(t,42),filename:null}},len:46};function Kt(t){const e=new Uint8Array(q.len);return q.put(e,0,t),e}const ue=Kr("tokenizer:inflate"),Je=256*1024,Qr=Kt(je.DataDescriptor),Le=Kt(je.EndOfCentralDirectory);class Ee{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Je)}async isZip(){return await this.peekSignature()===je.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(q)}async findEndOfCentralDirectoryLocator(){const e=this.tokenizer,r=Math.min(16*1024,e.fileInfo.size),s=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(s,{position:e.fileInfo.size-r});for(let i=s.length-4;i>=0;i--)if(s[i]===Le[0]&&s[i+1]===Le[1]&&s[i+2]===Le[2]&&s[i+3]===Le[3])return e.fileInfo.size-r+i;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){ue("Cannot reading central-directory without random-read support");return}ue("Reading central-directory...");const e=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){ue("Central-directory 32-bit signature found");const s=await this.tokenizer.readToken(Yr,r),i=[];this.tokenizer.setPosition(s.offsetOfStartOfCd);for(let a=0;a<s.nrOfEntriesOfSize;++a){const o=await this.tokenizer.readToken(Jr);if(o.signature!==je.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new fe(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),i.push(o),ue(`Add central-directory file-entry: n=${a+1}/${i.length}: filename=${i[a].filename}`)}return this.tokenizer.setPosition(e),i}this.tokenizer.setPosition(e)}async unzip(e){const r=await this.readCentralDirectory();if(r)return this.iterateOverCentralDirectory(r,e);let s=!1;do{const i=await this.readLocalFileHeader();if(!i)break;const a=e(i);s=!!a.stop;let o;if(await this.tokenizer.ignore(i.extraFieldLength),i.dataDescriptor&&i.compressedSize===0){const c=[];let u=Je;ue("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let d=-1;for(;d<0&&u===Je;){u=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),d=es(this.syncBuffer.subarray(0,u),Qr);const l=d>=0?d:u;if(a.handler){const m=new Uint8Array(l);await this.tokenizer.readBuffer(m),c.push(m)}else await this.tokenizer.ignore(l)}ue(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),a.handler&&await this.inflate(i,ts(c),a.handler)}else a.handler?(ue(`Reading compressed-file-data: ${i.compressedSize} bytes`),o=new Uint8Array(i.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(i,o,a.handler)):(ue(`Ignoring compressed-file-data: ${i.compressedSize} bytes`),await this.tokenizer.ignore(i.compressedSize));if(ue(`Reading data-descriptor at pos=${this.tokenizer.position}`),i.dataDescriptor&&(await this.tokenizer.readToken(yt)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-yt.len}`)}while(!s)}async iterateOverCentralDirectory(e,r){for(const s of e){const i=r(s);if(i.handler){this.tokenizer.setPosition(s.relativeOffsetOfLocalHeader);const a=await this.readLocalFileHeader();if(a){await this.tokenizer.ignore(a.extraFieldLength);const o=new Uint8Array(s.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(a,o,i.handler)}}if(i.stop)break}}async inflate(e,r,s){if(e.compressedMethod===0)return s(r);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);ue(`Decompress filename=${e.filename}, compressed-size=${r.length}`);const i=await Ee.decompressDeflateRaw(r);return s(i)}static async decompressDeflateRaw(e){const r=new ReadableStream({start(a){a.enqueue(e),a.close()}}),s=new DecompressionStream("deflate-raw"),i=r.pipeThrough(s);try{const o=await new Response(i).arrayBuffer();return new Uint8Array(o)}catch(a){const o=a instanceof Error?`Failed to deflate ZIP entry: ${a.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){const e=await this.tokenizer.peekToken(q);if(e===je.LocalFileHeader){const r=await this.tokenizer.readToken(Xr);return r.filename=await this.tokenizer.readToken(new fe(r.filenameLength,"utf-8")),r}if(e===je.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}function es(t,e){const r=t.length,s=e.length;if(s>r)return-1;for(let i=0;i<=r-s;i++){let a=!0;for(let o=0;o<s;o++)if(t[i+o]!==e[o]){a=!1;break}if(a)return i}return-1}function ts(t){const e=t.reduce((i,a)=>i+a.length,0),r=new Uint8Array(e);let s=0;for(const i of t)r.set(i,s),s+=i.length;return r}class rs{constructor(e){this.tokenizer=e}inflate(){const e=this.tokenizer;return new ReadableStream({async pull(r){const s=new Uint8Array(1024),i=await e.readBuffer(s,{mayBeLess:!0});if(i===0){r.close();return}r.enqueue(s.subarray(0,i))}}).pipeThrough(new DecompressionStream("gzip"))}}new globalThis.TextDecoder("utf8");new globalThis.TextEncoder;Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function vt(t){const{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}function ss(t,e){if(e==="utf-16le"){const r=[];for(let s=0;s<t.length;s++){const i=t.charCodeAt(s);r.push(i&255,i>>8&255)}return r}if(e==="utf-16be"){const r=[];for(let s=0;s<t.length;s++){const i=t.charCodeAt(s);r.push(i>>8&255,i&255)}return r}return[...t].map(r=>r.charCodeAt(0))}function ns(t,e=0){const r=Number.parseInt(new fe(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let s=8*32;for(let i=e;i<e+148;i++)s+=t[i];for(let i=e+156;i<e+512;i++)s+=t[i];return r===s}const is={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4},as=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],os=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"],De=4100,cs=De-2,xe=1024*1024,wt=1024,ls=2**31-1,ae=16*1024*1024,He=xe,Ct=xe,ds=ae,us=1,jt=100,Qe=ae,Ft=64,kt=He,ms=256,xs=512,fs=ae,ps=512,hs=512,Nt=256,St=He,Dt=He,gs=He,Tt=ae,bs=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),ys=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],vs=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);class ve extends Error{}function ws(t){var i;const e=t==null?void 0:t.streamReader;if(((i=e==null?void 0:e.constructor)==null?void 0:i.name)!=="WebStreamByobReader")return t;const{reader:r}=e,s=async()=>{await r.cancel(),r.releaseLock()};return e.close=s,e.abort=async()=>{e.interrupted=!0,await s()},t}function ot(t,e,r){if(!Number.isFinite(t)||t<0||t>e)throw new ve(`${r} has invalid size ${t} (maximum ${e} bytes)`);return t}async function ge(t,e,{maximumLength:r=ae,reason:s="skip"}={}){const i=ot(e,r,s);await t.ignore(i)}async function et(t,e,r,{maximumLength:s=e.length,reason:i="read"}={}){const a=e.length,o=ot(a,s,i);return t.readBuffer(e,{...r,length:o})}async function Cs(t,{maximumLength:e=xe}={}){const i=new ReadableStream({start(d){d.enqueue(t),d.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),a=[];let o=0;try{for(;;){const{done:d,value:l}=await i.read();if(d)break;if(o+=l.length,o>e)throw await i.cancel(),new Error(`ZIP entry decompressed data exceeds ${e} bytes`);a.push(l)}}finally{i.releaseLock()}const c=new Uint8Array(o);let u=0;for(const d of a)c.set(d,u),u+=d.length;return c}const Xt=134695760,$e=16,js=$e-1;function Fs(t,e){if(t.length<$e)return-1;const r=t.length-$e;for(let s=0;s<=r;s++)if(q.get(t,s)===Xt&&q.get(t,s+8)===e+s)return s;return-1}function ks(t){return(t.codePointAt(0)&32)!==0}function Ns(t,e){const r=new Uint8Array(e);let s=0;for(const i of t)r.set(i,s),s+=i.length;return r}async function Ss(t,{shouldBuffer:e,maximumLength:r=xe}={}){const{syncBuffer:s}=t,{length:i}=s,a=[];let o=0;for(;;){const c=await t.tokenizer.peekBuffer(s,{mayBeLess:!0}),u=Fs(s.subarray(0,c),o),d=u>=0?0:c===i?Math.min(js,c-1):0,l=u>=0?u:c-d;if(l===0)break;if(o+=l,o>r)throw new Error(`ZIP entry compressed data exceeds ${r} bytes`);if(e){const m=new Uint8Array(l);await t.tokenizer.readBuffer(m),a.push(m)}else await t.tokenizer.ignore(l);if(u>=0)break}if(J(t.tokenizer)||(t.knownSizeDescriptorScannedBytes+=o),!!e)return Ns(a,o)}function Ds(t,e){return J(t.tokenizer)?Math.max(0,ae-(t.tokenizer.position-e)):Math.max(0,xe-t.knownSizeDescriptorScannedBytes)}async function Ts(t,e,{shouldBuffer:r,maximumDescriptorLength:s=xe}={}){if(e.dataDescriptor&&e.compressedSize===0)return Ss(t,{shouldBuffer:r,maximumLength:s});if(!r){await ge(t.tokenizer,e.compressedSize,{maximumLength:J(t.tokenizer)?xe:t.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}const i=Ps(t.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>i)throw new Error(`ZIP entry compressed data exceeds ${i} bytes`);const a=new Uint8Array(e.compressedSize);return await t.tokenizer.readBuffer(a),a}Ee.prototype.inflate=async function(t,e,r){if(t.compressedMethod===0)return r(e);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);const s=await Cs(e,{maximumLength:xe});return r(s)};Ee.prototype.unzip=async function(t){let e=!1,r=0;const s=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(Te(this.tokenizer,s,ae))throw new ve(`ZIP stream probing exceeds ${ae} bytes`);const i=await this.readLocalFileHeader();if(!i)break;if(r++,r>wt)throw new Error(`ZIP entry count exceeds ${wt}`);const a=t(i);e=!!a.stop,await this.tokenizer.ignore(i.extraFieldLength);const o=await Ts(this,i,{shouldBuffer:!!a.handler,maximumDescriptorLength:Math.min(xe,Ds(this,s))});if(a.handler&&await this.inflate(i,o,a.handler),i.dataDescriptor){const c=new Uint8Array($e);if(await this.tokenizer.readBuffer(c),q.get(c,0)!==Xt)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-c.length}`)}if(Te(this.tokenizer,s,ae))throw new ve(`ZIP stream probing exceeds ${ae} bytes`)}while(!e)};function Es(t,e){const r=t.getReader();let s=0,i=!1,a=!1;const o=async c=>{i||a||(a=!0,await r.cancel(c))};return new ReadableStream({async pull(c){if(s>=e){c.close(),await o();return}const{done:u,value:d}=await r.read();if(u||!d){i=!0,c.close();return}const l=e-s;if(d.length>l){c.enqueue(d.subarray(0,l)),s+=l,c.close(),await o();return}c.enqueue(d),s+=d.length},async cancel(c){await o(c)}})}async function As(t,e){return new ct(e).fromBlob(t)}function Et(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function me(t,e,r){r={offset:0,...r};for(const[s,i]of e.entries())if(r.mask){if(i!==(r.mask[s]&t[s+r.offset]))return!1}else if(i!==t[s+r.offset])return!1;return!0}function Is(t){return Number.isFinite(t)?Math.max(1,Math.trunc(t)):De}function Bs(t,e,r){return r===void 0?t.read(e):(r.throwIfAborted(),new Promise((s,i)=>{const a=()=>{r.removeEventListener("abort",o)},o=()=>{const c=r.reason;a(),(async()=>{try{await t.cancel(c)}catch{}})(),i(c)};r.addEventListener("abort",o,{once:!0}),(async()=>{try{const c=await t.read(e);a(),s(c)}catch(c){a(),i(c)}})()}))}function Rs(t){return Number.isFinite(t)?Math.max(0,Math.min(cs,Math.trunc(t))):0}function Os(t){return Number.isFinite(t)?Math.max(0,t):Number.MAX_SAFE_INTEGER}function J(t){const e=t.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function Te(t,e,r){return J(t)&&t.position-e>r}function Ps(t){const e=t.fileInfo.size,r=Number.isFinite(e)?Math.max(0,e-t.position):Number.MAX_SAFE_INTEGER;return Math.min(r,ls)}function Ls(t){if(t instanceof G||t instanceof ve)return!0;if(!(t instanceof Error))return!1;if(bs.has(t.message)||vs.has(t.code))return!0;for(const e of ys)if(t.message.startsWith(e))return!0;return!1}function At(t,e=xe){const r=[t.compressedSize,t.uncompressedSize];for(const s of r)if(!Number.isFinite(s)||s<0||s>e)return!1;return!0}function zs(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function Ms(t,e){e.startsWith("word/")&&(t.hasWordDirectory=!0),e.startsWith("ppt/")&&(t.hasPresentationDirectory=!0),e.startsWith("xl/")&&(t.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(t.hasThreeDimensionalModelEntry=!0)}function It(t){if(!(!t.hasContentTypesEntry||t.hasUnparseableContentTypes||t.isParsingContentTypes||t.hasParsedContentTypesEntry)){if(t.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(t.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(t.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(t.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function $s(t){const e=t.indexOf('.main+xml"');if(e===-1){const i="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return t.includes(`ContentType="${i}"`)?i:void 0}const r=t.slice(0,e),s=r.lastIndexOf('"');return r.slice(s+1)}class ct{constructor(e){Xe(this,"detectConfident",async e=>{if(this.buffer=new Uint8Array(De),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,J(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=Nt?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await ge(e,6,{maximumLength:6,reason:"ID3 header prefix"});const r=await e.readToken(is),s=J(e);if(!Number.isFinite(r)||r<0||s&&(r>Qe||e.position+r>Qe))return;if(e.position+r>e.fileInfo.size)return s?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await ge(e,r,{maximumLength:s?Qe:e.fileInfo.size,reason:"ID3 payload"})}catch(i){if(i instanceof G)return;throw i}return this.detectionReentryCount>=Nt?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let r;const s=zs();try{await new Ee(e).unzip(i=>{Ms(s,i.filename);const a=i.filename==="[Content_Types].xml",o=It(s);if(!a&&o)return r=o,{stop:!0};switch(i.filename){case"META-INF/mozilla.rsa":return r={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return r={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return At(i,Ct)?{async handler(c){const u=new TextDecoder("utf-8").decode(c).trim();r=Et(u)},stop:!0}:{};case"[Content_Types].xml":return s.hasContentTypesEntry=!0,At(i,Ct)?(s.isParsingContentTypes=!0,{async handler(c){const u=new TextDecoder("utf-8").decode(c),d=$s(u);d&&(r=Et(d)),s.hasParsedContentTypesEntry=!0,s.isParsingContentTypes=!1},stop:!0}):(s.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(i.filename)?(r={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(i){if(!Ls(i))throw i;s.isParsingContentTypes&&(s.isParsingContentTypes=!1,s.hasUnparseableContentTypes=!0)}return r??It(s)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);const r=new Uint8Array(8);return await e.readBuffer(r),me(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:me(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:me(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:me(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:me(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:me(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){const r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){const u=await e.peekNumber(Er);let d=128,l=0;for(;!(u&d)&&d!==0;)++l,d>>=1;const m=new Uint8Array(l+1);return await et(e,m,void 0,{maximumLength:m.length,reason:"EBML field"}),m}async function s(){const u=await r(),d=await r();d[0]^=128>>d.length-1;const l=Math.min(6,d.length),m=new DataView(u.buffer),x=new DataView(d.buffer,d.length-l,l);return{id:vt(m),len:vt(x)}}async function i(u){let d=0;for(;u>0;){if(d++,d>ms||Te(e,o,ae))return;const l=e.position,m=await s();if(m.id===17026){if(m.len>Ft)return;const x=ot(m.len,Ft,"EBML DocType");return(await e.readToken(new fe(x))).replaceAll(/\00.*$/g,"")}if(J(e)&&(!Number.isFinite(m.len)||m.len<0||m.len>kt)||(await ge(e,m.len,{maximumLength:J(e)?kt:e.fileInfo.size,reason:"EBML payload"}),--u,e.position<=l))return}}const a=await s(),o=e.position;switch(await i(a.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const r=ht.get(this.buffer,4),s=we.get(this.buffer,6);if(r>0&&r<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(s>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const r=new fe(4,"latin1").get(this.buffer,2);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new fe(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
2
+ `,"\r"," "," ","\0"].some(r=>this.checkString(r,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){const r={ext:"png",mime:"image/png"},s={ext:"apng",mime:"image/apng"};await e.ignore(8);async function i(){return{length:await e.readToken(Ar),type:await e.readToken(new fe(4,"latin1"))}}const a=J(e),o=e.position;let c=0,u=!1;do{if(c++,c>xs||Te(e,o,fs))break;const d=e.position,l=await i();if(l.length<0)return;if(l.type==="IHDR"){if(l.length!==13)return;u=!0}switch(l.type){case"IDAT":return r;case"acTL":return s;default:if(!u&&l.type!=="CgBI")return;if(a&&l.length>St)return u&&ks(l.type)?r:void 0;try{await ge(e,l.length+4,{maximumLength:a?St+4:e.fileInfo.size,reason:"PNG chunk payload"})}catch(m){if(!a&&(m instanceof ve||m instanceof G))return r;throw m}}if(e.position<=d)break}while(e.position+8<e.fileInfo.size);return r}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&this.buffer[8]&96){const r=new fe(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
3
+ `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let r=!1;try{async function s(){const c=new Uint8Array(16);return await et(e,c,void 0,{maximumLength:c.length,reason:"ASF header GUID"}),{id:c,size:Number(await e.readToken(Ir))}}await ge(e,30,{maximumLength:30,reason:"ASF header prelude"});const i=J(e),a=e.position;let o=0;for(;e.position+24<e.fileInfo.size&&(o++,!(o>ps||Te(e,a,ae)));){const c=e.position,u=await s();let d=u.size-24;if(!Number.isFinite(d)||d<0){r=!0;break}if(me(u.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const l=new Uint8Array(16);if(d-=await et(e,l,void 0,{maximumLength:l.length,reason:"ASF stream type GUID"}),me(l,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(me(l,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&d>Dt){r=!0;break}if(await ge(e,d,{maximumLength:i?Dt:e.fileInfo.size,reason:"ASF header payload"}),e.position<=c){r=!0;break}}}catch(s){if(s instanceof G||s instanceof ve)J(e)&&(r=!0);else throw s}return r?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new fe(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const r=new DataView(this.buffer.buffer).getUint32(12,!0);if(r>12&&this.buffer.length>=r+16)try{const s=new TextDecoder().decode(this.buffer.subarray(16,r+16));if(JSON.parse(s).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&ns(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){const r="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:r})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:r})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
4
+ `,{offset:2,encoding:r})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}});Xe(this,"detectImprecise",async e=>{this.buffer=new Uint8Array(De);const r=Os(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,r),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,r),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let s=0;s<=this.options.mpegOffsetTolerance;++s){const i=this.scanMpeg(s);if(i)return i}});const r=Rs(e==null?void 0:e.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:r},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return ws(_r(e,this.getTokenizerOptions()))}async parseTokenizer(e,r=0){this.detectionReentryCount=r;const s=e.position;for(const i of this.detectors){let a;try{a=await i.detect(e)}catch(o){if(o instanceof G||o instanceof ve)return;throw o}if(a)return a;if(s!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);const r=e instanceof Uint8Array?e:new Uint8Array(e);if((r==null?void 0:r.length)>1)return this.fromTokenizer(Vr(r,this.getTokenizerOptions()))}async fromBlob(e){var s;(s=this.options.signal)==null||s.throwIfAborted();const r=Wr(e,this.getTokenizerOptions());return this.fromTokenizer(r)}async fromStream(e){var s;(s=this.options.signal)==null||s.throwIfAborted();const r=this.createTokenizerFromWebStream(e);return this.fromTokenizer(r)}async toDetectionStream(e,r){const s=Is((r==null?void 0:r.sampleSize)??De);let i,a;const o=e.getReader({mode:"byob"});try{const{value:d,done:l}=await Bs(o,new Uint8Array(s),this.options.signal);if(a=d,!l&&d)try{i=await this.fromBuffer(d.subarray(0,s))}catch(m){if(!(m instanceof G))throw m;i=void 0}a=d}finally{o.releaseLock()}const c=new TransformStream({async start(d){d.enqueue(a)},transform(d,l){l.enqueue(d)}}),u=e.pipeThrough(c);return u.fileType=i,u}async detectGzip(e){var d;if(this.gzipProbeDepth>=us)return{ext:"gz",mime:"application/gzip"};const r=new rs(e),s=Es(r.inflate(),ds),i=J(e);let a,o,c,u;if(i){const l=new AbortController;a=setTimeout(()=>{l.abort(new DOMException(`Operation timed out after ${jt} ms`,"TimeoutError"))},jt),o=this.options.signal===void 0?l.signal:AbortSignal.any([this.options.signal,l.signal]),c=new ct({...this.options,signal:o}),c.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{u=await(c??this).fromStream(s)}catch(l){if((l==null?void 0:l.name)==="AbortError"&&((d=o==null?void 0:o.reason)==null?void 0:d.name)!=="TimeoutError")throw l}finally{clearTimeout(a),i||this.gzipProbeDepth--}return(u==null?void 0:u.ext)==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,r){return me(this.buffer,e,r)}checkString(e,r){return this.check(ss(e,r==null?void 0:r.encoding),r)}async readTiffTag(e){const r=await this.tokenizer.readToken(e?we:W);switch(await this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const r=await this.tokenizer.readToken(e?we:W);if(!(r>hs)&&!(J(this.tokenizer)&&2+r*12>Tt))for(let s=0;s<r;++s){const i=await this.readTiffTag(e);if(i)return i}}async readTiffHeader(e){const r={ext:"tif",mime:"image/tiff"},s=(e?we:W).get(this.buffer,2),i=(e?ht:q).get(this.buffer,4);if(s===42){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){const c=(e?we:W).get(this.buffer,8),u=(e?we:W).get(this.buffer,10);if(c===28&&u===254||c===31&&u===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(J(this.tokenizer)&&i>gs)return r;const a=J(this.tokenizer)?Tt:this.tokenizer.fileInfo.size;try{await ge(this.tokenizer,i,{maximumLength:a,reason:"TIFF IFD offset"})}catch(c){if(c instanceof G)return;throw c}let o;try{o=await this.readTiffIFD(e)}catch(c){if(c instanceof G)return;throw c}return o??r}if(s===43)return r}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(as);new Set(os);const Bt=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,lt=({name:t,control:e,disabled:r,campo:s,fileTypes:i,maxFileSize:a})=>{var S;const{field:o,fieldState:c}=R.useController({name:t,control:e}),{uploadFile:u,deleteUploadedFile:d,onUploadStart:l,onUploadEnd:m}=pe(),[x,p]=f.useState({status:"idle"}),b=f.useRef(null),[F,C]=f.useState(!1),v=f.useRef(!0),y=f.useRef(l);y.current=l;const g=f.useRef(m);g.current=m,f.useEffect(()=>()=>{v.current=!1},[]);const j=typeof o.value=="string"&&o.value?o.value:null,O=f.useCallback(async N=>{var P,$,ee;if(i&&i.length>0){const U=await As(N),z=(U==null?void 0:U.ext)??"",K=(U==null?void 0:U.mime)??"",I=((P=N.name.split(".").pop())==null?void 0:P.toLowerCase())??"",M=N.type.toLowerCase();if(!i.some(ye=>{const se=ye.toLowerCase();return!!(z&&(se===z||se===K)||K&&se.endsWith("/*")&&K.startsWith(se.slice(0,-1))||!z&&(se===I||se===M||se.endsWith("/*")&&M.startsWith(se.slice(0,-1))))})){p({status:"error",message:`Tipo de arquivo não permitido. Permitidos: ${i.join(", ")}`});return}}if(a&&N.size>a){p({status:"error",message:`Arquivo muito grande. Tamanho máximo: ${Bt(a)}`});return}if(!u){p({status:"error",message:"Preview: upload não disponível sem configuração."});return}p({status:"uploading",fileName:N.name,progress:0}),($=y.current)==null||$.call(y);try{if(j&&d)try{await d(j)}catch{}const U=await u(N,s??t,z=>{v.current&&p(K=>K.status==="uploading"?{...K,progress:Math.min(100,z)}:K)});if(!v.current)return;o.onChange(U),p({status:"done",uploadId:U,fileName:N.name,size:N.size})}catch{if(!v.current)return;p({status:"error",message:"Falha no upload. Tente novamente."})}finally{v.current&&((ee=g.current)==null||ee.call(g))}},[u,d,j,s,t,o,i,a]),T=f.useCallback(N=>{var $;const P=($=N.target.files)==null?void 0:$[0];P&&O(P),N.target.value=""},[O]),B=f.useCallback(()=>{var N;j&&d&&((N=y.current)==null||N.call(y),d(j).catch(()=>{}).finally(()=>{var P;(P=g.current)==null||P.call(g)})),o.onChange(""),p({status:"idle"}),b.current&&(b.current.value="")},[o,j,d]);if(x.status==="done"||x.status==="idle"&&!!j){const N=x.status==="done"?x.fileName:"Arquivo enviado",P=x.status==="done"?x.size:null;return n.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-500 bg-green-500/5 px-4 py-3 gap-2",children:[n.jsxs("svg",{className:"shrink-0 text-green-500",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[n.jsx("rect",{width:"20",height:"20",rx:"4",fill:"currentColor",fillOpacity:"0.15"}),n.jsx("path",{d:"M5 10.5L8.5 14L15 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N}),P!==null&&n.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Bt(P)}),!r&&n.jsx("button",{type:"button",onClick:B,className:"ml-2 shrink-0 text-muted-foreground hover:text-destructive transition-colors","aria-label":"Remover arquivo",children:"✕"})]})}if(x.status==="uploading"){const{fileName:N,progress:P}=x;return n.jsxs("div",{className:"rounded-lg border border-input px-4 py-3 space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N}),n.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[P,"%"]})]}),n.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full bg-primary transition-all duration-200 rounded-full",style:{width:`${P}%`}})})]})}const D=x.status==="error";return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{role:"button",tabIndex:r?-1:0,"aria-label":"Selecionar arquivo",className:w.cn("flex items-center justify-center rounded-lg border-2 border-dashed px-4 py-6 transition-colors cursor-pointer",F?"border-primary bg-primary/5":D||c.error?"border-destructive bg-destructive/5":"border-input hover:border-muted-foreground hover:bg-muted/20",r&&"opacity-50 cursor-not-allowed"),onClick:()=>{var N;return!r&&((N=b.current)==null?void 0:N.click())},onKeyDown:N=>{var P;(N.key==="Enter"||N.key===" ")&&((P=b.current)==null||P.click())},onDragOver:N=>{N.preventDefault(),r||C(!0)},onDragLeave:()=>C(!1),onDrop:r?void 0:N=>{var $;N.preventDefault(),C(!1);const P=($=N.dataTransfer.files)==null?void 0:$[0];P&&O(P)},onBlur:o.onBlur,children:[n.jsx("input",{ref:b,type:"file",onChange:T,disabled:r,className:"sr-only"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:F?"Solte o arquivo aqui":"Clique ou arraste um arquivo"})]}),D&&n.jsxs("p",{className:"text-sm text-destructive",children:[x.message," · ",n.jsx("button",{type:"button",className:"underline hover:no-underline",onClick:()=>p({status:"idle"}),children:"Tentar novamente"})]}),!D&&((S=c.error)==null?void 0:S.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Us={cpf:t=>t.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"),telefone:t=>{const e=t.replace(/\D/g,"").slice(0,11);return e.length<=10?e.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{4})(\d)/,"$1-$2"):e.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{5})(\d)/,"$1-$2")},cep:t=>t.replace(/\D/g,"").slice(0,8).replace(/(\d{5})(\d)/,"$1-$2")},be=({name:t,control:e,placeholder:r,maskType:s,disabled:i,readOnly:a})=>{var l;const{field:o,fieldState:c}=R.useController({name:t,control:e}),u=Us[s||""],d=f.useCallback(m=>{o.onChange(u?u(m.target.value):m.target.value)},[o,u]);return n.jsxs("div",{className:"space-y-1",children:[n.jsx(w.Input,{name:o.name,value:o.value||"",onChange:d,onBlur:o.onBlur,placeholder:r,disabled:i,readOnly:a,className:w.cn(c.error&&"border-destructive focus-visible:ring-destructive")}),((l=c.error)==null?void 0:l.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Ge=({name:t,control:e})=>{const{field:r}=R.useController({name:t,control:e});return n.jsx("input",{type:"hidden",...r,value:r.value??""})},Yt=t=>t.replace(/\D/g,""),_s=t=>{const e=Yt(t).slice(0,8);return e.length<=5?e:`${e.slice(0,5)}-${e.slice(5)}`},Vs=async(t,e)=>{const r=await fetch(`https://viacep.com.br/ws/${t}/json/`,{signal:e});if(!r.ok)throw new Error("Falha ao consultar CEP");return r.json()},dt=({name:t,control:e,placeholder:r="00000-000",disabled:s,readOnly:i,cepFillMap:a})=>{var y,g;const{field:o,fieldState:c}=R.useController({name:t,control:e}),{setValue:u}=R.useFormContext(),{cepLookup:d}=pe(),[l,m]=f.useState("idle"),[x,p]=f.useState(null),b=f.useRef(null),F=f.useRef(!0);f.useEffect(()=>()=>{var j;F.current=!1,(j=b.current)==null||j.abort()},[]);const C=f.useCallback(async()=>{var O;o.onBlur();const j=Yt(o.value??"");if(j.length===8){(O=b.current)==null||O.abort(),b.current=new AbortController,m("loading"),p(null);try{let T;if(d){const D=b.current;if(T=await d(j,D.signal),D.signal.aborted||!F.current)return}else{const D=await Vs(j,b.current.signal);if(!F.current)return;if(D.erro){m("error"),p("CEP não encontrado");return}T={logradouro:D.logradouro,bairro:D.bairro,cidade:D.localidade,estado:D.uf}}if(!F.current)return;if(T.erro){m("error"),p("CEP não encontrado");return}const B=t.includes(".")?`${t.substring(0,t.lastIndexOf("."))}.`:"",k=(D,S,N)=>{if(!N)return;const P=a!=null&&a[D]?`${B}${a[D]}`:`${B}${S}`;u(P,N,{shouldDirty:!0,shouldValidate:!0})};k("logradouro","_address_logradouro",T.logradouro),k("bairro","_address_bairro",T.bairro),k("cidade","_address_cidade",T.cidade),k("estado","_address_estado",T.estado),m("success")}catch(T){if(T instanceof Error&&T.name==="AbortError"||!F.current)return;m("error"),p("Erro ao buscar CEP")}}},[o,d,u,t,a]),v=f.useCallback(j=>{o.onChange(_s(j.target.value))},[o]);return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"relative",children:[n.jsx(w.Input,{name:o.name,value:o.value||"",onChange:v,onBlur:C,placeholder:r,disabled:s,readOnly:i,className:w.cn("pr-9",c.error&&"border-destructive focus-visible:ring-destructive")}),n.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:[l==="loading"&&n.jsx(A.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}),l==="success"&&n.jsx(A.Check,{className:"h-4 w-4 text-green-500"}),l==="error"&&n.jsx(A.AlertCircle,{className:"h-4 w-4 text-destructive"})]})]}),(((y=c.error)==null?void 0:y.message)||x)&&n.jsx("p",{className:"text-sm text-destructive",children:((g=c.error)==null?void 0:g.message)||x})]})},Ws=({field:t,control:e,nameOverride:r})=>{const s={name:r,control:e,placeholder:t.placeholder};switch(t.tipo){case h.FieldType.TEXTO:return n.jsx(ne,{...s,type:"text"});case h.FieldType.EMAIL:return n.jsx(ne,{...s,type:"email"});case h.FieldType.NUMBER:return n.jsx(ne,{...s,type:"number"});case h.FieldType.TEXTAREA:return n.jsx(We,{...s});case h.FieldType.SELECT:return n.jsx(qe,{...s,options:t.opcoes??[]});case h.FieldType.RADIO:return n.jsx(nt,{...s,options:t.opcoes??[]});case h.FieldType.CHECKBOX:return n.jsx(Ze,{name:r,control:e,label:t.label});case h.FieldType.CHECKBOX_GROUP:return n.jsx(st,{...s,options:t.opcoes??[]});case h.FieldType.DATE:return n.jsx(Fe,{...s,validacao:t.validacao});case h.FieldType.DATETIME:return n.jsx(Fe,{...s,isDatetime:!0,validacao:t.validacao});case h.FieldType.FILE:return n.jsx(lt,{name:r,control:e});case h.FieldType.TELEFONE:return n.jsx(be,{...s,maskType:"telefone"});case h.FieldType.CPF:return n.jsx(be,{...s,maskType:"cpf"});case h.FieldType.CEP:return n.jsx(dt,{name:r,control:e,placeholder:t.placeholder});case h.FieldType.HIDDEN:return n.jsx(Ge,{name:r,control:e});default:return console.error(`[DFFieldArray] Tipo de sub-campo "${t.tipo}" não suportado em FIELD_ARRAY. Usando DFTextField como fallback.`),n.jsx(ne,{...s,type:"text"})}},Jt=({name:t,control:e,subFields:r=[],minItems:s=1,maxItems:i,itemLabel:a="Item",addLabel:o})=>{var C;const{fields:c,append:u,remove:d}=R.useFieldArray({control:e,name:t}),{errors:l}=R.useFormState({control:e}),m=(C=l[t])==null?void 0:C.message,x=f.useCallback(()=>{const v={};for(const y of r)y.initialValue!==void 0?v[y.nome]=y.initialValue:y.defaultValue!==void 0&&(v[y.nome]=y.defaultValue);return v},[r]);f.useEffect(()=>{if(c.length<s)for(let v=c.length;v<s;v++)u(x())},[s]);const p=[...r].sort((v,y)=>v.ordem-y.ordem),b=!i||c.length<i,F=o??`Adicionar ${a.toLowerCase()}`;return n.jsxs("div",{className:"space-y-3",children:[c.map((v,y)=>n.jsxs("div",{className:"rounded-lg border p-4",style:{borderColor:"var(--t-border)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary shrink-0",children:y+1}),n.jsxs("span",{className:"text-sm font-semibold",children:[a," ",y+1]})]}),c.length>s&&n.jsx(w.Button,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(y),"aria-label":`Remover ${a.toLowerCase()} ${y+1}`,className:"text-muted-foreground hover:text-destructive",children:n.jsx(A.Trash2,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"grid grid-cols-12 gap-4",children:p.map(g=>{const j=`${t}.${y}.${g.nome}`,T=`span ${g.tamanho??12}`,B=n.jsx(Ws,{field:g,control:e,nameOverride:j});return g.tipo===h.FieldType.CHECKBOX||g.tipo===h.FieldType.HIDDEN?n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:T},children:B},g.id):n.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:T},children:[n.jsxs("label",{className:"font-medium flex items-center gap-1 text-sm text-foreground",children:[g.label,g.obrigatorio&&n.jsx("span",{className:"text-destructive",children:"*"})]}),B,g.hint&&n.jsx("p",{className:"text-xs text-muted-foreground",children:g.hint})]},g.id)})})]},v.id)),b&&n.jsxs(w.Button,{type:"button",variant:"outline",className:"w-full",onClick:()=>u(x()),children:[n.jsx(A.Plus,{className:"w-4 h-4"}),F]}),i&&n.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",i," ",a.toLowerCase(),i>1?"s":""]}),m&&n.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[n.jsx(A.AlertCircle,{className:"w-4 h-4 shrink-0"}),m]})]})},Rt=t=>`R$ ${(t/100).toFixed(2).replace(".",",")}`,qs=(t,e)=>{const r=new Date(t.slice(0,10)+"T00:00:00Z"),s=new Date(e.slice(0,10)+"T00:00:00Z");return Math.round((s.getTime()-r.getTime())/864e5)+1},Zs=(t,e)=>{const r=[],s=new Date(t.slice(0,10)+"T00:00:00Z"),i=new Date(e.slice(0,10)+"T00:00:00Z");let a=0;for(;s<=i&&a<60;)r.push(s.toISOString().slice(0,10)),s.setUTCDate(s.getUTCDate()+1),a++;return r},Hs=t=>{const[e,r,s]=t.split("-").map(Number),i=new Date(Date.UTC(e,r-1,s)),a=String(s).padStart(2,"0"),o=String(r).padStart(2,"0"),c=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(i),u=c.charAt(0).toUpperCase()+c.slice(1);return`${a}/${o} - ${u}`},Gs=(t,e)=>{const r=s=>{const[i,a,o]=s.slice(0,10).split("-");return`${o}/${a}/${i}`};return`${r(t)} a ${r(e)}`},Qt=({name:t,control:e})=>{var K;const{field:r,fieldState:s}=R.useController({name:t,control:e}),{externalData:i={}}=pe(),a=r.value??null,o=(K=s.error)==null?void 0:K.message,c=I=>i[`evento.${I}`]??i[I],u=c("dataInicioEvento")??"",d=c("dataFimEvento")??"",l=Number(c("valor")??0),m=Number(c("valorPorDia")??0),x=c("vagasTotal"),p=c("vagasPorDia"),b=c("vagasMasculinas"),F=c("vagasFemininas"),C=x!=null?Number(x):null,v=p!=null?Number(p):null,y=b!=null?Number(b):null,g=F!=null?Number(F):null,{dias:j,eventoMultiDia:O}=f.useMemo(()=>{if(!u||!d)return{dias:[],eventoMultiDia:!1};const I=Zs(u,d),M=qs(u,d);return{dias:I,eventoMultiDia:M>1}},[u,d]),T=f.useMemo(()=>y!=null&&y>0&&g!=null&&g>0,[y,g]),B=f.useMemo(()=>y!=null&&g==null?"masculino":g!=null&&y==null?"feminino":null,[y,g]),k=(a==null?void 0:a.tipo)??null,D=(a==null?void 0:a.data)??null,S=(a==null?void 0:a.genero)??null,N=f.useRef(a);N.current=a;const P=f.useRef(r.onChange);P.current=r.onChange,f.useEffect(()=>{var I,M,oe;B&&((I=N.current)==null?void 0:I.genero)!==B&&P.current({tipo:((M=N.current)==null?void 0:M.tipo)??null,data:((oe=N.current)==null?void 0:oe.data)??null,genero:B})},[B]);const $=f.useCallback(I=>{const M={tipo:I,data:null};(T||B)&&(M.genero=S??B??void 0),r.onChange(M)},[r,T,B,S]),ee=f.useCallback(I=>{const M={tipo:"por_dia",data:I};(T||B)&&(M.genero=S??B??void 0),r.onChange(M)},[r,T,B,S]),U=f.useCallback(I=>{r.onChange({tipo:k,data:D,genero:I})},[r,k,D]),z=f.useCallback(I=>k===I,[k]);return n.jsxs("div",{className:"space-y-3",children:[T&&n.jsxs("div",{className:"flex items-center gap-2 px-1",children:[n.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Você é:"}),n.jsx("div",{className:"flex gap-2",children:["masculino","feminino"].map(I=>n.jsx("button",{type:"button",onClick:()=>U(I),className:w.cn("px-3 py-1 rounded-full text-xs font-medium border transition-all",S===I?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:border-primary/50"),children:I==="masculino"?"Masculino":"Feminino"},I))})]}),n.jsxs("button",{type:"button",onClick:()=>$("todos_os_dias"),style:z("todos_os_dias")?void 0:{borderColor:"var(--t-border)"},className:w.cn("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",z("todos_os_dias")?"border-primary bg-primary/5":"hover:border-primary/50"),children:[n.jsx("div",{className:w.cn("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",z("todos_os_dias")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.jsx(A.CalendarCheck2,{className:"w-4 h-4"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-semibold text-sm",children:"Participar todos os dias"}),u&&d?n.jsx("p",{className:"text-xs text-muted-foreground",children:Gs(u,d)}):n.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Datas do evento"})]}),n.jsxs("div",{className:"text-right shrink-0",children:[l>0&&n.jsx("p",{className:w.cn("font-bold text-sm",z("todos_os_dias")?"text-primary":"text-foreground"),children:Rt(l)}),C!=null&&C>0&&n.jsxs("p",{className:"text-xs flex items-center justify-end gap-1 text-muted-foreground",children:[n.jsx(A.Users,{className:"w-3 h-3"}),C," vagas disponíveis"]})]})]}),O&&v!=null&&v!==0?n.jsxs("button",{type:"button",onClick:()=>$("por_dia"),style:z("por_dia")?void 0:{borderColor:"var(--t-border)"},className:w.cn("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",z("por_dia")?"border-primary bg-primary/5":"hover:border-primary/50"),children:[n.jsx("div",{className:w.cn("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",z("por_dia")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.jsx(A.CalendarDays,{className:"w-4 h-4"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-semibold text-sm",children:"Participar um dia"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado abaixo"})]}),n.jsxs("div",{className:"text-right shrink-0",children:[m>0&&n.jsx("p",{className:w.cn("font-bold text-sm",z("por_dia")?"text-primary":"text-foreground"),children:Rt(m)}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"por dia"})]})]}):!O&&u?n.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg border border-input bg-muted/30",children:[n.jsx(A.Info,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-muted-foreground"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:'Este evento ocorre em apenas 1 dia — a opção "Participar um dia" não é necessária.'})]}):null,k==="por_dia"&&n.jsxs("div",{className:"pl-2 space-y-2",children:[n.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Selecione o dia:"}),j.length===0?n.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nenhuma data configurada no evento"}):j.map(I=>n.jsxs("button",{type:"button",onClick:()=>ee(I),style:D!==I?{borderColor:"var(--t-border)"}:void 0,className:w.cn("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",D===I?"border-primary bg-primary/5":"hover:border-primary/50"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:w.cn("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center transition-colors",D===I?"border-primary bg-primary":""),style:D!==I?{borderColor:"var(--t-border)"}:void 0,children:D===I&&n.jsx("span",{className:"w-2 h-2 rounded-full bg-white"})}),n.jsx("span",{className:"text-sm",children:Hs(I)})]}),v!=null&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:[v," vagas"]})]},I))]}),o&&n.jsx("p",{className:"text-sm text-destructive",children:o})]})},Ot=.0315,Pt=.124,Lt=7,zt=12,er=[{id:"pix",label:"PIX",description:"Transferência instantânea (à vista)",Icon:A.Smartphone,taxa:0},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:A.Banknote,taxa:0},{id:"cartao",label:"Cartão de Crédito",description:"Débito ou crédito na maquininha",Icon:A.CreditCard,taxa:Ot,taxaLabel:`Taxa: ${(Ot*100).toFixed(2).replace(".",",")}%`}],tr=[{id:"pix",label:"PIX à Vista",description:"Pagamento instantâneo sem parcelamento",Icon:A.Smartphone,taxa:0},{id:"pix_parcelado",label:"PIX Parcelado",description:`Parcelado em até ${Lt}x sem juros`,Icon:A.Smartphone,taxa:0,parcelas:Lt},{id:"cartao",label:"Cartão de Crédito",description:`Parcelado em até ${zt}x`,Icon:A.CreditCard,taxa:Pt,parcelas:zt,taxaLabel:`Taxa: ${(Pt*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:A.Banknote,taxa:0}],ze=t=>`R$ ${(t/100).toFixed(2).replace(".",",")}`,Mt=(t,e)=>Math.round(t*(1+e)*100)/100,Ks=(t,e)=>Math.round(t/e*100)/100,rr=({name:t,control:e,relatedFieldName:r="tipo_participacao"})=>{var y;const{field:s,fieldState:i}=R.useController({name:t,control:e}),{externalData:a={},paymentMethodOptions:o}=pe(),c=s.value??null,u=(y=i.error)==null?void 0:y.message,d=R.useWatch({control:e,name:r}),l=(d==null?void 0:d.tipo)??null,m=g=>a[`evento.${g}`]??a[g],x=Number(m("valor")??0),p=Number(m("valorPorDia")??0),b=l==="por_dia"&&p>0?p:x,F=l==="por_dia"?(o==null?void 0:o.porDia)??er:(o==null?void 0:o.todosOsDias)??tr,C=l==="por_dia"?(()=>{if(!(d!=null&&d.data))return"Um dia";const g=d.data.split("-");if(g.length===3){const[j,O,T]=g;return`${T}/${O}/${j}`}return d.data})():"Todos os dias",v=g=>{if(g.disabled)return;const j=Mt(b,g.taxa),O={metodo:g.id,valorTotal:j};g.parcelas&&(O.parcelas=g.parcelas),s.onChange(O)};return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between rounded-xl border px-4 py-3",style:{borderColor:"var(--t-border)"},children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Tipo de participação"}),n.jsx("p",{className:"font-semibold",children:C})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Valor base"}),n.jsx("p",{className:"text-lg font-bold text-primary",children:ze(b)})]})]}),n.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/30 px-3 py-2.5",style:{borderColor:"var(--t-border)"},children:[n.jsx(A.Info,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),n.jsxs("p",{className:"text-xs",children:[n.jsx("span",{className:"font-bold",children:"Importante:"})," Para validar a inscrição e garantir sua vaga, o pagamento deve ser realizado no ato da inscrição."]})]}),n.jsx("p",{className:"text-sm font-semibold text-primary",children:"Selecione a forma de pagamento:"}),n.jsx("div",{className:"space-y-3",children:F.map(g=>{const{Icon:j}=g,O=(c==null?void 0:c.metodo)===g.id,T=Mt(b,g.taxa),B=!!g.parcelas&&g.parcelas>1,k=B?Ks(T,g.parcelas):null;return n.jsxs("button",{type:"button",disabled:g.disabled,onClick:()=>v(g),style:O?void 0:{borderColor:"var(--t-border)"},className:w.cn("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all",O?"border-primary bg-primary/5":"hover:border-primary/50",g.disabled&&"opacity-50 cursor-not-allowed"),children:[n.jsx("div",{className:w.cn("flex items-center justify-center w-10 h-10 rounded-lg shrink-0 transition-colors",O?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.jsx(j,{className:"h-5 w-5"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-semibold text-sm leading-tight",children:g.label}),n.jsx("p",{className:"text-xs text-muted-foreground",children:g.description}),g.taxaLabel&&n.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["* ",g.taxaLabel]}),g.taxa>0&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",ze(T)]})]}),n.jsx("div",{className:"text-right shrink-0",children:B?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.parcelas,"x de"]}),n.jsx("p",{className:"text-base font-bold text-primary",children:ze(k)})]}):n.jsx("p",{className:"text-base font-bold text-primary",children:ze(T)})})]},g.id)})}),u&&n.jsx("p",{className:"text-xs text-destructive",children:u})]})},sr=({name:t,control:e,label:r,termoTexto:s,termoPdfUrl:i,termoPdfUploadId:a})=>{var g;const{field:o,fieldState:c}=R.useController({name:t,control:e}),{resolveTermsUploadUrl:u}=pe(),d=!!c.error,l=(g=c.error)==null?void 0:g.message,[m,x]=f.useState(null),[p,b]=f.useState(!1);f.useEffect(()=>{if(!a||!u){x(null);return}let j=!1;return b(!0),u(a).then(O=>{j||x(O)}).catch(()=>{j||x(null)}).finally(()=>{j||b(!1)}),()=>{j=!0}},[a,u]);const F=o.value==="accepted",C=m||i||null,v=!!(s||C||a),y=!!C;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:w.cn("rounded-lg border p-4 space-y-4 transition-colors",d?"border-destructive bg-destructive/5":F?"border-green-500 bg-green-500/5":"border-input"),children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(A.ScrollText,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"text-sm font-medium",children:r||"Termos e condições"})]}),v?n.jsxs(w.Dialog,{children:[n.jsx(w.DialogTrigger,{asChild:!0,children:n.jsxs(w.Button,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",disabled:p,children:[p?n.jsx(A.Loader2,{className:"h-3 w-3 animate-spin"}):n.jsx(A.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]})}),n.jsxs(w.DialogContent,{className:"max-w-2xl flex flex-col max-h-[90vh]",children:[n.jsx(w.DialogHeader,{children:n.jsxs(w.DialogTitle,{className:"flex items-center gap-2",children:[n.jsx(A.ScrollText,{className:"h-4 w-4"}),"Termos e condições"]})}),y?n.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[n.jsx("iframe",{src:C,className:"w-full h-[62vh] rounded border",title:"Termos e condições",sandbox:"allow-same-origin allow-scripts allow-popups"}),n.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:["Bloqueado pelo seu navegador?"," ",n.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"underline text-primary",children:"Abrir em nova aba"})]})]}):n.jsx(w.ScrollArea,{className:"flex-1 max-h-[62vh] rounded border p-4 bg-muted/20",children:n.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:s})})]})]}):n.jsx("span",{className:"text-xs text-muted-foreground italic",children:a&&p?"Carregando PDF...":"Conteúdo não configurado"})]}),n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[n.jsx(w.Checkbox,{className:"mt-0.5",checked:F,onCheckedChange:j=>o.onChange(j?"accepted":"")}),n.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito ",r?`"${r}"`:"os termos e condições"]}),F&&n.jsx(A.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]}),d&&n.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[n.jsx(A.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),l||"Você precisa aceitar os termos para continuar"]})]})},Xs=({name:t,control:e,placeholder:r,disabled:s,readOnly:i})=>{var l;const{field:a,fieldState:o}=R.useController({name:t,control:e}),[c,u]=f.useState(!1),d=!!o.error;return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"relative",children:[n.jsx(w.Input,{...a,value:a.value??"",type:c?"text":"password",placeholder:r,disabled:s,readOnly:i,className:w.cn("pr-10",d&&"border-destructive focus-visible:ring-destructive")}),n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>u(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":c?"Ocultar senha":"Mostrar senha",children:c?n.jsx(A.EyeOff,{size:16}):n.jsx(A.Eye,{size:16})})]}),((l=o.error)==null?void 0:l.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},nr=({name:t,control:e,label:r,disabled:s,readOnly:i})=>{var u;const{field:a,fieldState:o}=R.useController({name:t,control:e}),c=!!a.value;return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[n.jsx(w.Switch,{checked:c,onCheckedChange:d=>!i&&a.onChange(d),disabled:s||i,onBlur:a.onBlur}),n.jsx("span",{className:"text-sm leading-none",children:r})]}),((u=o.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},Ys=({name:t,control:e,minValue:r=0,maxValue:s=100,step:i=1,disabled:a,readOnly:o})=>{var l;const{field:c,fieldState:u}=R.useController({name:t,control:e}),d=c.value??r;return f.useEffect(()=>{(c.value===void 0||c.value===null)&&c.onChange(r)},[]),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(w.Slider,{min:r,max:s,step:i,value:[d],onValueChange:m=>!o&&c.onChange(m[0]),disabled:a||o,className:"flex-1"}),n.jsx("span",{className:"text-sm font-medium text-primary min-w-[3rem] text-right tabular-nums",children:d})]}),n.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[n.jsx("span",{children:r}),n.jsx("span",{children:s})]}),((l=u.error)==null?void 0:l.message)&&n.jsx("p",{className:"text-sm text-destructive",children:u.error.message})]})},tt=t=>/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t),Js=({name:t,control:e,disabled:r,readOnly:s})=>{var d;const{field:i,fieldState:a}=R.useController({name:t,control:e}),o=i.value||"#000000",[c,u]=f.useState(o);return f.useEffect(()=>{u(o)},[o]),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("input",{type:"color",value:tt(o)?o:"#000000",disabled:r||s,onChange:l=>i.onChange(l.target.value),className:"h-10 w-14 cursor-pointer rounded-lg border border-input bg-transparent p-1 disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx(w.Input,{type:"text",value:c,readOnly:s,disabled:r,onChange:l=>{const m=l.target.value;u(m),tt(m)&&i.onChange(m.toUpperCase())},onBlur:()=>{tt(c)||u(o),i.onBlur()},className:w.cn("flex-1 font-mono uppercase",a.error&&"border-destructive focus-visible:ring-destructive"),maxLength:7,placeholder:"#000000"})]}),((d=a.error)==null?void 0:d.message)&&n.jsx("p",{className:"text-sm text-destructive",children:a.error.message})]})},Qs=({name:t,control:e,options:r,placeholder:s,disabled:i,readOnly:a})=>{var k,D;const{field:o,fieldState:c}=R.useController({name:t,control:e}),[u,d]=f.useState(""),[l,m]=f.useState(!1),[x,p]=f.useState(-1),b=f.useRef(null),F=f.useRef(null),C=`autocomplete-${t}-listbox`,v=((k=r.find(S=>S.valor===o.value))==null?void 0:k.label)??"",y=u.length>0?r.filter(S=>S.label.toLowerCase().includes(u.toLowerCase())):r;f.useEffect(()=>{const S=N=>{b.current&&!b.current.contains(N.target)&&(m(!1),d(""),p(-1))};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);const g=()=>{m(!1),d(""),p(-1)};f.useEffect(()=>{if(x<0||!F.current)return;const S=F.current.querySelector(`[id="${C}-option-${x}"]`);S==null||S.scrollIntoView({block:"nearest"})},[x,C]);const j=S=>{S.disabled||(o.onChange(S.valor),g())},O=()=>{o.onChange(""),d(""),p(-1)},T=S=>{if(!l){(S.key==="ArrowDown"||S.key==="ArrowUp")&&(S.preventDefault(),m(!0),p(0));return}switch(S.key){case"ArrowDown":S.preventDefault(),p(N=>N<y.length-1?N+1:N);break;case"ArrowUp":S.preventDefault(),p(N=>N>0?N-1:0);break;case"Enter":S.preventDefault(),x>=0&&y[x]&&!y[x].disabled&&j(y[x]);break;case"Escape":S.preventDefault(),g();break;case"Tab":g();break}},B=l&&x>=0?`${C}-option-${x}`:void 0;return n.jsxs("div",{className:"space-y-1",ref:b,children:[n.jsxs("div",{className:"relative",children:[n.jsx(w.Input,{type:"text",role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-controls":C,"aria-activedescendant":B,value:l?u:v,placeholder:s??"Buscar...",disabled:i,readOnly:a,onChange:S=>{d(S.target.value),p(-1),m(!0)},onFocus:()=>!a&&m(!0),onKeyDown:T,className:w.cn("pr-8",c.error&&"border-destructive focus-visible:ring-destructive"),autoComplete:"off"}),n.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:o.value?n.jsx("button",{type:"button",onClick:O,className:"text-[var(--t-text-muted)] hover:text-[var(--t-text)]",tabIndex:-1,"aria-label":"Limpar seleção",children:n.jsx(A.X,{size:14})}):n.jsx(A.ChevronDown,{size:16,className:"text-muted-foreground pointer-events-none","aria-hidden":"true"})}),l&&!i&&!a&&n.jsx("ul",{role:"listbox",id:C,ref:F,"aria-label":"Opções disponíveis",className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-input bg-popover shadow-lg",children:y.length===0?n.jsx("li",{role:"option","aria-selected":!1,className:"px-3 py-2 text-sm text-muted-foreground",children:"Nenhuma opção encontrada"}):y.map((S,N)=>n.jsx("li",{id:`${C}-option-${N}`,role:"option","aria-selected":o.value===S.valor,"aria-disabled":S.disabled,onMouseDown:()=>j(S),className:["flex cursor-pointer items-center px-3 py-2 text-sm",S.disabled?"cursor-not-allowed opacity-40":N===x?"bg-accent":"hover:bg-accent",o.value===S.valor?"font-medium text-primary":"text-foreground"].join(" "),children:S.label},S.valor))})]}),((D=c.error)==null?void 0:D.message)&&n.jsx("p",{className:"text-sm text-destructive",role:"alert",children:c.error.message})]})},ir=({name:t,control:e,placeholder:r,disabled:s,readOnly:i})=>{var u;const{field:a,fieldState:o}=R.useController({name:t,control:e}),c=!!o.error;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(w.Input,{...a,value:a.value??"",type:"time",placeholder:r,disabled:s,readOnly:i,className:w.cn(c&&"border-destructive focus-visible:ring-destructive")}),((u=o.error)==null?void 0:u.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},en=({name:t,control:e,startLabel:r="Data inicial",endLabel:s="Data final",disabled:i,readOnly:a})=>{var m;const{field:o,fieldState:c}=R.useController({name:t,control:e}),u=o.value??{},d=(x,p)=>{o.onChange({...u,[x]:p})},l=!!c.error;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(w.Label,{children:r}),n.jsx(w.Input,{type:"date",value:u.start??"",disabled:i,readOnly:a,onChange:x=>d("start",x.target.value),max:u.end??void 0,className:w.cn(l&&"border-destructive focus-visible:ring-destructive")})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(w.Label,{children:s}),n.jsx(w.Input,{type:"date",value:u.end??"",disabled:i,readOnly:a,onChange:x=>d("end",x.target.value),min:u.start??void 0,className:w.cn(l&&"border-destructive focus-visible:ring-destructive")})]})]}),((m=c.error)==null?void 0:m.message)&&n.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},tn=({name:t,control:e,maxRating:r=5,disabled:s,readOnly:i})=>{var d;const{field:a,fieldState:o}=R.useController({name:t,control:e}),c=a.value??0,u=Array.from({length:r},(l,m)=>m+1);return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[u.map(l=>n.jsx("button",{type:"button",disabled:s||i,onClick:()=>a.onChange(l===c?0:l),className:"transition-transform hover:scale-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":`${l} estrela${l>1?"s":""}`,children:n.jsx(A.Star,{size:24,className:"transition-colors",fill:l<=c?"var(--color-primary)":"transparent",stroke:l<=c?"var(--color-primary)":"currentColor"})},l)),c>0&&n.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c,"/",r]})]}),((d=o.error)==null?void 0:d.message)&&n.jsx("p",{className:"text-sm text-destructive",children:o.error.message})]})},rn=({field:t,name:e,control:r,disabled:s,readOnly:i})=>{const a=s||t.isDisabled,o=i||t.isReadOnly;switch(t.tipo){case h.FieldType.EMAIL:return n.jsx(ne,{name:e,control:r,type:"email",placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.NUMBER:return n.jsx(ne,{name:e,control:r,type:"number",placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.PASSWORD:return n.jsx(ne,{name:e,control:r,type:"password",placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.TELEFONE:return n.jsx(be,{name:e,control:r,maskType:"telefone",placeholder:t.placeholder??"(00) 00000-0000",disabled:a,readOnly:o});case h.FieldType.CPF:return n.jsx(be,{name:e,control:r,maskType:"cpf",placeholder:t.placeholder??"000.000.000-00",disabled:a,readOnly:o});case h.FieldType.CEP:return n.jsx(be,{name:e,control:r,maskType:"cep",placeholder:t.placeholder??"00000-000",disabled:a,readOnly:o});case h.FieldType.TEXTAREA:return n.jsx(We,{name:e,control:r,placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.SELECT:return n.jsx(qe,{name:e,control:r,options:t.opcoes??[],placeholder:t.placeholder,disabled:a,readOnly:o});case h.FieldType.CHECKBOX:return n.jsx(Ze,{name:e,control:r,label:t.label??"",disabled:a,readOnly:o});case h.FieldType.SWITCH:return n.jsx(nr,{name:e,control:r,label:t.label??"",disabled:a,readOnly:o});case h.FieldType.DATE:return n.jsx(Fe,{name:e,control:r,disabled:a,readOnly:o});case h.FieldType.TIME:return n.jsx(ir,{name:e,control:r,disabled:a,readOnly:o});case h.FieldType.HIDDEN:return n.jsx(Ge,{name:e,control:r});default:return n.jsx(ne,{name:e,control:r,type:"text",placeholder:t.placeholder,disabled:a,readOnly:o})}},sn=({name:t,control:e,subSchema:r,disabled:s,readOnly:i})=>{if(!r||r.fields.length===0)return null;const a=[...r.fields].sort((o,c)=>o.ordem-c.ordem);return n.jsxs("div",{className:"rounded-xl border border-input bg-muted/30 p-4 space-y-4",children:[r.titulo&&n.jsx("h4",{className:"text-sm font-semibold text-muted-foreground",children:r.titulo}),n.jsx("div",{className:"grid grid-cols-12 gap-4",children:a.map(o=>{const c=`${t}.${o.nome}`,u=o.tipo===h.FieldType.CHECKBOX||o.tipo===h.FieldType.SWITCH||o.tipo===h.FieldType.HIDDEN,d=o.tamanho??6;return n.jsxs("div",{className:`col-span-${d}`,children:[!u&&n.jsxs("label",{className:"mb-1 block text-sm font-medium text-foreground",children:[o.label,o.obrigatorio&&n.jsx("span",{className:"text-destructive",children:" *"})]}),n.jsx(rn,{field:o,name:c,control:e,disabled:s,readOnly:i})]},o.id)})})]})},ar=({field:t,control:e,nameOverride:r})=>{var c,u;const s=r??t.nome,{componentMapper:i}=pe(),a=i==null?void 0:i[t.tipo];if(a)return n.jsx(a,{name:s,control:e,field:t});const o={name:s,control:e,placeholder:t.placeholder,disabled:t.isDisabled,readOnly:t.isReadOnly};switch(t.tipo){case h.FieldType.TEXTO:return n.jsx(ne,{...o,type:"text"});case h.FieldType.EMAIL:return n.jsx(ne,{...o,type:"email"});case h.FieldType.NUMBER:return n.jsx(ne,{...o,type:"number"});case h.FieldType.PASSWORD:return n.jsx(Xs,{...o});case h.FieldType.TEXTAREA:return n.jsx(We,{...o});case h.FieldType.SELECT:return n.jsx(qe,{...o,options:t.opcoes??[]});case h.FieldType.AUTOCOMPLETE:return n.jsx(Qs,{...o,options:t.opcoes??[]});case h.FieldType.SWITCH:return n.jsx(nr,{name:s,control:e,label:t.label,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.SLIDER:return n.jsx(Ys,{name:s,control:e,minValue:t.minValue,maxValue:t.maxValue,step:t.step,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.RATING:return n.jsx(tn,{name:s,control:e,maxRating:t.maxRating,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.COLOR:return n.jsx(Js,{name:s,control:e,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.TIME:return n.jsx(ir,{...o});case h.FieldType.DATE_RANGE:return n.jsx(en,{name:s,control:e,startLabel:t.dateRangeStartLabel,endLabel:t.dateRangeEndLabel,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.RADIO:return n.jsx(nt,{...o,options:t.opcoes??[]});case h.FieldType.CHECKBOX:return n.jsx(Ze,{name:s,control:e,label:t.label,disabled:t.isDisabled,readOnly:t.isReadOnly});case h.FieldType.CHECKBOX_GROUP:return n.jsx(st,{...o,options:t.opcoes??[]});case h.FieldType.DATE:return n.jsx(Fe,{name:s,control:e,disabled:t.isDisabled,readOnly:t.isReadOnly,validacao:t.validacao});case h.FieldType.DATETIME:return n.jsx(Fe,{name:s,control:e,isDatetime:!0,disabled:t.isDisabled,readOnly:t.isReadOnly,validacao:t.validacao});case h.FieldType.FILE:return n.jsx(lt,{name:s,control:e,disabled:t.isDisabled,fileTypes:(c=t.validacao)==null?void 0:c.fileTypes,maxFileSize:(u=t.validacao)==null?void 0:u.maxFileSize});case h.FieldType.TELEFONE:return n.jsx(be,{...o,maskType:"telefone"});case h.FieldType.CPF:return n.jsx(be,{...o,maskType:"cpf"});case h.FieldType.CEP:return n.jsx(dt,{name:s,control:e,placeholder:t.placeholder,disabled:t.isDisabled,readOnly:t.isReadOnly,cepFillMap:t.cepFillMap});case h.FieldType.HIDDEN:return n.jsx(Ge,{name:s,control:e});case h.FieldType.PARTICIPATION_TYPE:return n.jsx(Qt,{name:s,control:e});case h.FieldType.PAYMENT_METHOD:return n.jsx(rr,{name:s,control:e,relatedFieldName:t.relatedFieldName});case h.FieldType.TERMS:return n.jsx(sr,{name:s,control:e,label:t.label,termoTexto:t.termoTexto,termoPdfUrl:t.termoPdfUrl,termoPdfUploadId:t.termoPdfUploadId});case h.FieldType.FIELD_ARRAY:return n.jsx(Jt,{name:s,control:e,subFields:t.subFields,minItems:t.minItems,maxItems:t.maxItems,itemLabel:t.itemLabel,addLabel:t.addLabel});case h.FieldType.SUB_FORM:return n.jsx(sn,{name:s,control:e,subSchema:t.subSchema,disabled:t.isDisabled,readOnly:t.isReadOnly});default:return n.jsx(ne,{...o,type:"text"})}},nn=({container:t,control:e})=>{var F;const{externalData:r={},fieldResolvers:s}=pe(),i=t.icone?_e[t.icone]:void 0,a=r,o=f.useMemo(()=>Ve(t,a),[t,JSON.stringify(a)]),c=f.useMemo(()=>[...o.campos].sort((C,v)=>C.ordem-v.ordem),[o.campos]),u=R.useWatch({control:e}),{wrapperClass:d,wrapperStyle:l,headerClass:m,headerStyle:x,tmpl:p}=qt(),b=C=>{if(!h.evaluateFieldCondition(C.condicional,u,r))return null;let y=C;if(C.resolvePropsKey&&(s!=null&&s[C.resolvePropsKey])){const B=s[C.resolvePropsKey](C,u,r);y={...C,...B}}if(y.opcoesFromVar){const B=r[y.opcoesFromVar];Array.isArray(B)&&(y={...y,opcoes:B.map(k=>typeof k=="string"?{valor:k,label:k}:k&&typeof k=="object"&&"valor"in k&&"label"in k?k:{valor:String(k),label:String(k)})})}const g=y.tamanho??12,j=y.inicioColuna,O=j?`${j} / span ${g}`:`span ${g}`,T=n.jsx(ar,{field:y,control:e});return y.tipo===h.FieldType.CHECKBOX||y.tipo===h.FieldType.HIDDEN||y.tipo===h.FieldType.SWITCH?n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:O},children:T},y.id):n.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:O},children:[n.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[y.label,y.obrigatorio&&n.jsx("span",{className:"text-destructive",children:"*"})]}),T,y.hint&&n.jsx("p",{className:"text-xs text-muted-foreground",children:y.hint})]},y.id)};return n.jsxs("div",{className:d,style:l,children:[(o.titulo||i)&&n.jsx("div",{className:m,style:x,children:n.jsxs("div",{className:"flex items-center gap-3",children:[i&&n.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:n.jsx(i,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),n.jsxs("div",{children:[n.jsx("h3",{className:((F=p.typography)==null?void 0:F.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:o.titulo}),o.descricao&&n.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:o.descricao})]})]})}),n.jsx("div",{className:"p-6 grid grid-cols-12 gap-4",children:c.map(b)})]})},an=({container:t,control:e})=>{var B;const{externalData:r={}}=pe(),s=t.nome??"__invalid__",i=t.minItems??1,a=t.maxItems,o=t.itemLabel??"Item",c=t.icone?_e[t.icone]:void 0,u=r,d=f.useMemo(()=>Ve(t,u),[t,JSON.stringify(u)]),l=f.useMemo(()=>[...d.campos].sort((k,D)=>k.ordem-D.ordem),[d.campos]),m=f.useCallback(()=>{const k={};for(const D of l)D.initialValue!==void 0?k[D.nome]=typeof D.initialValue=="string"?Q(D.initialValue,u):D.initialValue:D.defaultValue!==void 0&&(k[D.nome]=D.defaultValue);return k},[l,u]),{fields:x,append:p,remove:b}=R.useFieldArray({control:e,name:s});f.useEffect(()=>{if(t.nome&&x.length<i)for(let k=x.length;k<i;k++)p(m())},[i]);const F=R.useWatch({control:e}),C=f.useMemo(()=>{const k=F[s];return Array.isArray(k)?k:[]},[F,s]),{wrapperClass:v,wrapperStyle:y,headerClass:g,headerStyle:j,tmpl:O}=qt();if(!t.nome)return console.error("[RepeatableContainerRenderer] container.nome é obrigatório para containers repetíveis. Container id:",t.id),null;const T=(k,D)=>{const S=C[D]??{};if(!h.evaluateFieldCondition(k.condicional,S,r))return null;const P=`${s}.${D}.${k.nome}`,$=k.tamanho??12,ee=k.inicioColuna,U=ee?`${ee} / span ${$}`:`span ${$}`,z=n.jsx(ar,{field:k,control:e,nameOverride:P});return k.tipo===h.FieldType.CHECKBOX||k.tipo===h.FieldType.HIDDEN?n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:U},children:z},`${k.id}-${D}`):n.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:U},children:[n.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[k.label,k.obrigatorio&&n.jsx("span",{className:"text-destructive",children:"*"})]}),z,k.hint&&n.jsx("p",{className:"text-xs text-muted-foreground",children:k.hint})]},`${k.id}-${D}`)};return n.jsxs("div",{className:v,style:y,children:[(d.titulo||c)&&n.jsx("div",{className:g,style:j,children:n.jsxs("div",{className:"flex items-center gap-3",children:[c&&n.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:n.jsx(c,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),n.jsxs("div",{children:[n.jsx("h3",{className:((B=O.typography)==null?void 0:B.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:d.titulo}),d.descricao&&n.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:d.descricao})]})]})}),n.jsxs("div",{className:"p-6 space-y-4",children:[x.map((k,D)=>n.jsxs("div",{className:"border border-input rounded-lg p-4 bg-muted/30",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shrink-0 bg-primary text-primary-foreground",children:D+1}),n.jsxs("span",{className:"text-sm font-semibold",children:[o," ",D+1]})]}),x.length>i&&n.jsx("button",{type:"button",onClick:()=>b(D),className:"inline-flex items-center justify-center rounded-md p-1.5 text-destructive hover:bg-destructive/10 transition-colors","aria-label":"Remover item",children:n.jsx(A.Trash2,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"grid grid-cols-12 gap-4",children:l.map(S=>T(S,D))})]},k.id)),(!a||x.length<a)&&n.jsxs("button",{type:"button",className:"w-full flex items-center justify-center gap-2 py-2 px-4 border border-input rounded-lg text-sm hover:bg-accent transition-colors",onClick:()=>p(m()),children:[n.jsx(A.Plus,{className:"w-4 h-4"}),"Adicionar ",o.toLowerCase()]}),a&&n.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",a," ",o.toLowerCase(),a>1?"s":""]})]})]})},or=t=>t.container.repeatable&&t.container.nome?n.jsx(an,{...t}):n.jsx(nn,{...t}),cr=({step:t,control:e,externalData:r={}})=>{const s=f.useMemo(()=>[...t.containers].sort((a,o)=>a.ordem-o.ordem),[t.containers]),i=R.useWatch({control:e});return n.jsx("div",{className:"grid grid-cols-12 gap-4",children:s.map(a=>{if(a.condicional&&!h.evaluateFieldCondition(a.condicional,i,r))return null;const o=a.tamanho??12,c=a.inicioColuna,u=c?`${c} / span ${o}`:`span ${o}`;return n.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:u},children:n.jsx(or,{container:a,control:e})},a.id)})})},Ae=f.createContext({submitting:!1,warnings:{},requestSubmit:()=>{}}),on=Ae.Provider,cn=()=>{const t=dr("useFormApi"),e=f.useContext(Ae);return{change:(r,s)=>t.setValue(r,s,{shouldValidate:!0,shouldDirty:!0}),reset:r=>t.reset(r),submit:e.requestSubmit,getState:()=>{const{errors:r,isDirty:s,isValid:i}=t.formState;return{values:t.getValues(),errors:Object.fromEntries(Object.entries(r).map(([a,o])=>[a,o==null?void 0:o.message])),warnings:e.warnings,dirty:s,valid:i,submitting:e.submitting}}}},lr=()=>{const t=dr("useFormState"),e=f.useContext(Ae),r=R.useWatch({control:t.control}),{errors:s,isDirty:i,isValid:a}=t.formState;return{values:r,errors:Object.fromEntries(Object.entries(s).map(([o,c])=>[o,c==null?void 0:c.message])),warnings:e.warnings,dirty:i,valid:a,submitting:e.submitting}},ln=t=>{var a;const e=R.useFormContext(),{warnings:r}=f.useContext(Ae),s=R.useWatch({control:e.control,name:t}),i=e.getFieldState(t,e.formState);return{value:s,error:(a=i.error)==null?void 0:a.message,warning:r[t],dirty:i.isDirty,touched:i.isTouched,valid:!i.error}},dn=t=>{var a;const{control:e}=R.useFormContext(),{warnings:r}=f.useContext(Ae),{field:s,fieldState:i}=R.useController({name:t,control:e});return{input:{name:s.name,value:s.value,onChange:s.onChange,onBlur:s.onBlur,ref:s.ref},meta:{error:(a=i.error)==null?void 0:a.message,warning:r[t],touched:i.isTouched,dirty:i.isDirty,valid:!i.error}}},dr=t=>{const e=R.useFormContext();if(!e)throw new Error(`[SchemaForms] O hook '${t}' foi chamado fora de um <FormRenderer />. Certifique-se de que o componente está dentro da árvore de renderização do formulário.`);return e},$t=({stepIndex:t,totalSteps:e,step:r,defaultValues:s,externalData:i,fieldErrors:a,isSubmitting:o,isUploading:c=!1,submitError:u,validatorMapper:d={},onWarningsChange:l,onValuesChange:m,onSubmit:x,onBack:p})=>{const b=t===e-1,F=f.useMemo(()=>JSON.stringify(i),[i]),C=f.useMemo(()=>Ut(r,i,d),[r.id,F]),v=f.useMemo(()=>_t(r,i,d),[r.id,F]),[y,g]=f.useState({}),j=f.useRef(l);j.current=l;const O=i,T=f.useMemo(()=>Wt(r,O),[r,F]),B=R.useForm({resolver:C,defaultValues:s,mode:"onTouched"}),{control:k,handleSubmit:D,setError:S,clearErrors:N,setValue:P}=B;f.useEffect(()=>{N();for(const[E,ie]of Object.entries(a))S(E,{type:"server",message:ie})},[a,S,N]);const $=f.useMemo(()=>r.containers.filter(E=>!E.repeatable).flatMap(E=>E.campos).filter(E=>!!E.condicional),[r.containers]),ee=f.useMemo(()=>r.containers.filter(E=>!!E.condicional),[r.containers]),U=f.useMemo(()=>r.containers.filter(E=>!E.repeatable).flatMap(E=>E.campos).filter(E=>{var ie;return E.condicional&&((ie=E.setValues)==null?void 0:ie.length)}),[r.containers]),z=f.useMemo(()=>r.containers.filter(E=>E.repeatable&&!!E.nome).map(E=>({container:E,fields:E.campos.filter(ie=>!!ie.condicional)})).filter(E=>E.fields.length>0),[r.containers]),K=f.useRef({}),I=f.useRef(!0),M=R.useWatch({control:k}),oe=f.useRef(m);oe.current=m,f.useEffect(()=>{var E;(E=oe.current)==null||E.call(oe,M)},[M]),f.useEffect(()=>{let E=!1;return v(M).then(le=>{var L;E||(g(le),(L=j.current)==null||L.call(j,le))}).catch(le=>{E||console.error("[StepForm] warnComputer error:",le)}),()=>{E=!0}},[M,v]),f.useEffect(()=>{var le;if(!$.length&&!U.length&&!ee.length&&!z.length)return;const E=M;for(const L of $)if(!h.evaluateFieldCondition(L.condicional,E,i)){if(N(L.nome),L.tipo===h.FieldType.FIELD_ARRAY){const _=E[L.nome];Array.isArray(_)&&_.forEach((Z,X)=>{(L.subFields??[]).forEach(te=>N(`${L.nome}.${X}.${te.nome}`))})}if(L.clearedValue!==void 0){const _=L.clearedValue??"";E[L.nome]!==_&&P(L.nome,_,{shouldValidate:!1})}}for(const L of ee)if(!h.evaluateFieldCondition(L.condicional,E,i))if(L.repeatable&&L.nome)(Array.isArray(E[L.nome])?E[L.nome]:[]).forEach((Z,X)=>{for(const te of L.campos)N(`${L.nome}.${X}.${te.nome}`)});else for(const _ of L.campos){N(_.nome);const Z=_.clearedValue!==void 0?_.clearedValue:void 0;Z!==void 0&&E[_.nome]!==Z&&P(_.nome,Z,{shouldValidate:!1})}for(const{container:L,fields:de}of z){const _=L.nome,Z=Array.isArray(E[_])?E[_]:[];for(let X=0;X<Z.length;X++){const te=Z[X];for(const Y of de)if(!h.evaluateFieldCondition(Y.condicional,te,i)&&(N(`${_}.${X}.${Y.nome}`),Y.clearedValue!==void 0)){const Ne=Y.clearedValue??"";te[Y.nome]!==Ne&&P(`${_}.${X}.${Y.nome}`,Ne,{shouldValidate:!1})}}}const ie=I.current;for(const L of U){const de=h.evaluateFieldCondition(L.condicional,E,i),_=ie?de:K.current[L.nome]??!1;if(de&&!_&&((le=L.setValues)!=null&&le.length))for(const Z of L.setValues){const X=typeof Z.valor=="string"?Q(Z.valor,O):Z.valor;P(Z.campo,X,{shouldValidate:!1})}K.current[L.nome]=de}I.current=!1},[M,$,U,ee,z,i,P,N]);const ye=T.icone?_e[T.icone]:void 0,se=f.useMemo(()=>()=>{B.handleSubmit(x)()},[x]);return n.jsx(R.FormProvider,{...B,children:n.jsx(on,{value:{submitting:o,warnings:y,requestSubmit:se},children:n.jsx("form",{onSubmit:D(x),noValidate:!0,onKeyDown:E=>{E.key==="Enter"&&E.target.tagName==="INPUT"&&E.preventDefault()},children:n.jsxs("div",{className:"space-y-6",children:[T.showLabel!==!1&&n.jsxs("div",{className:"text-center space-y-2",children:[ye&&n.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl flex items-center justify-center",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:n.jsx(ye,{className:"w-6 h-6",style:{color:"var(--t-primary)"}})}),n.jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:T.titulo}),T.descricao&&n.jsx("p",{className:"text-sm text-muted-foreground",children:T.descricao})]}),n.jsx(cr,{step:T,control:k,externalData:i}),n.jsxs("div",{className:"flex items-center justify-between gap-4 pt-6 pb-2",children:[n.jsxs(w.Button,{type:"button",variant:"outline",onClick:p,disabled:t===0||c,className:w.cn(t>0&&!c&&"border-primary/40 text-primary hover:bg-primary/5"),children:[n.jsx(A.ChevronLeft,{className:"w-4 h-4"}),n.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),n.jsxs("span",{className:"text-xs font-semibold tabular-nums sm:hidden text-muted-foreground",children:[t+1,"/",e]}),n.jsxs(w.Button,{type:"submit",disabled:o||c,children:[o?n.jsx(A.Loader2,{className:"w-4 h-4 animate-spin"}):c?n.jsx(A.Loader2,{className:"w-4 h-4 animate-spin"}):b?n.jsx(A.Check,{className:"w-4 h-4"}):n.jsx(A.ChevronRight,{className:"w-4 h-4"}),n.jsx("span",{className:"hidden sm:inline",children:b?"Finalizar":"Próximo"})]})]}),u&&n.jsx("p",{className:"text-sm text-destructive mt-2 text-center",children:u})]})})})})},Ue=t=>{if(t)return _e[t]},un=({steps:t,currentStep:e,onStepClick:r})=>n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:t.map((s,i)=>n.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(i),onKeyDown:a=>a.key==="Enter"&&(r==null?void 0:r(i)),className:w.cn("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:i===e?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:i<e?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:i<e?n.jsx(A.Check,{className:"w-4 h-4"}):i+1},s.id))}),mn=({steps:t,currentStep:e,onStepClick:r})=>n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:t.map((s,i)=>{const a=Ue(s.icone)??A.CircleDot;return n.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(i),onKeyDown:o=>o.key==="Enter"&&(r==null?void 0:r(i)),className:w.cn("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:i===e?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:i<e?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:i<e?n.jsx(A.Check,{className:"w-4 h-4"}):n.jsx(a,{className:"w-4 h-4"})},s.id)})}),xn=({steps:t,currentStep:e,position:r,orientation:s="horizontal",onStepClick:i})=>s==="vertical"?n.jsx("div",{className:"flex flex-col gap-0",children:t.map((a,o)=>{const c=Ue(a.icone)??A.CircleDot,u=o===e,d=o<e,l=o===t.length-1;return n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center",children:[n.jsx("button",{type:"button",onClick:()=>i==null?void 0:i(o),className:w.cn("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",i&&"cursor-pointer hover:opacity-80"),style:u?{background:"var(--t-primary)",color:"#fff",boxShadow:"0 0 10px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#fff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?n.jsx(A.Check,{className:"w-3.5 h-3.5"}):n.jsx(c,{className:"w-3.5 h-3.5"})}),!l&&n.jsx("div",{className:"w-[2px] my-1",style:{height:"24px",background:d?"#22c55e":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]}),n.jsx("span",{className:"text-sm font-medium leading-tight mt-1.5",style:u?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:a.label??a.id})]},a.id)})}):n.jsx("div",{className:"w-full flex items-start",children:t.map((a,o)=>{const c=Ue(a.icone)??A.CircleDot,u=o===e,d=o<e,l=o===t.length-1;return n.jsxs("div",{className:w.cn("flex items-start",!l&&"flex-1"),children:[n.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-[56px] shrink-0 mx-auto",children:[n.jsx("button",{type:"button",onClick:()=>i==null?void 0:i(o),className:w.cn("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",i&&"cursor-pointer hover:opacity-80"),style:u?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 12px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#ffffff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?n.jsx(A.Check,{className:"w-4 h-4"}):n.jsx(c,{className:"w-4 h-4"})}),n.jsx("span",{className:"text-[10px] font-medium text-center leading-tight line-clamp-2 px-0.5",style:u?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:a.label??a.id})]}),!l&&n.jsx("div",{className:"flex-1 h-[1.5px] mt-5 mx-1",style:{background:d?"linear-gradient(90deg, var(--t-primary), color-mix(in srgb, var(--t-primary) 40%, transparent))":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]},a.id)})}),ur=({steps:t,currentStep:e,onStepClick:r,className:s,forceShow:i})=>{const a=Se.useTemplate(),{layout:o}=a;if(!o.showStepIndicators||t.length<=1&&!i)return null;const c=o.stepIndicatorVariant??"numbers",u=o.stepIndicatorPosition??"top-center",d=o.stepIndicatorOrientation??"horizontal",l=(e+1)/t.length*100,m=t[e],x=Ue(m==null?void 0:m.icone)??A.CircleDot,p=n.jsx("div",{className:"h-1 rounded-full overflow-hidden",style:{background:"color-mix(in srgb, var(--t-primary) 15%, transparent)"},children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${l}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),b=n.jsxs("div",{className:"block sm:hidden space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:"var(--t-primary)",color:"#fff"},children:n.jsx(x,{className:"w-5 h-5"})}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-sm font-semibold leading-tight truncate",style:{color:"var(--t-text)"},children:(m==null?void 0:m.label)??(m==null?void 0:m.id)}),n.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",e+1," de ",t.length]})]})]}),p]}),F=n.jsxs("div",{className:"hidden sm:block",children:[c==="numbers"&&n.jsx(un,{steps:t,currentStep:e,onStepClick:r}),c==="icons"&&n.jsx(mn,{steps:t,currentStep:e,onStepClick:r}),c==="icons-labeled"&&n.jsx(xn,{steps:t,currentStep:e,position:u,orientation:d,onStepClick:r})]}),C=o.showProgressBar?n.jsx("div",{className:"hidden sm:block",children:p}):null;return d==="vertical"?n.jsxs("div",{className:w.cn("flex gap-6 items-start",s),children:[b,n.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[F,C&&n.jsx("div",{className:"flex-1 pt-4",children:C})]})]}):n.jsxs("div",{className:w.cn("space-y-3",s),children:[b,n.jsxs("div",{className:"hidden sm:block space-y-3",children:[F,C]})]})},fn=(t,e,r)=>{var a;const s={...e},i=r;for(const o of t.containers){for(const c of o.campos)if(s[c.nome]===void 0&&(c.initialValue!==void 0?s[c.nome]=typeof c.initialValue=="string"?Q(c.initialValue,i):c.initialValue:c.defaultValue!==void 0&&(s[c.nome]=c.defaultValue)),c.tipo===h.FieldType.FIELD_ARRAY&&((a=c.subFields)!=null&&a.length)){const u=s[c.nome];Array.isArray(u)&&u.length>0&&(s[c.nome]=u.map(d=>{const l={...d};for(const m of c.subFields)l[m.nome]===void 0&&(m.initialValue!==void 0?l[m.nome]=typeof m.initialValue=="string"?Q(m.initialValue,i):m.initialValue:m.defaultValue!==void 0&&(l[m.nome]=m.defaultValue));return l}))}if(o.repeatable&&o.nome){const c=s[o.nome];Array.isArray(c)&&c.length>0&&(s[o.nome]=c.map(u=>{const d={...u};for(const l of o.campos)d[l.nome]===void 0&&(l.initialValue!==void 0?d[l.nome]=typeof l.initialValue=="string"?Q(l.initialValue,i):l.initialValue:l.defaultValue!==void 0&&(d[l.nome]=l.defaultValue));return d}))}}return s},pn=({schema:t,initialValues:e={},initialStep:r=0,onSubmitStep:s,onComplete:i,template:a,formTitle:o,externalData:c={},fieldErrors:u={},uploadFile:d,deleteUploadedFile:l,cepLookup:m,resolveTermsUploadUrl:x,fieldResolvers:p,validatorMapper:b,componentMapper:F,paymentMethodOptions:C,onValuesChange:v,className:y,StepIndicator:g=ur})=>{const[j,O]=f.useState(()=>r),[T,B]=f.useState({...e}),[k,D]=f.useState(()=>r),[S,N]=f.useState(!1),[P,$]=f.useState(null),[ee,U]=f.useState({}),[z,K]=f.useState(!1),I=f.useRef(0),M=f.useCallback(()=>{I.current+=1,I.current===1&&f.startTransition(()=>K(!0))},[]),oe=f.useCallback(()=>{I.current=Math.max(0,I.current-1),I.current===0&&f.startTransition(()=>K(!1))},[]),ye=f.useRef(x);ye.current=x;const se=f.useCallback(V=>ye.current(V),[]),E=!!x,ie=f.useRef(l);ie.current=l;const le=f.useCallback(V=>ie.current(V),[]),L=!!l,de=f.useMemo(()=>JSON.stringify(c),[c]),_=f.useMemo(()=>JSON.stringify(t.stepConfig),[t.stepConfig]),Z=f.useMemo(()=>{const V=Se.getTemplateConfig(a);return t.stepConfig?{...V,layout:{...V.layout,...t.stepConfig}}:V},[a,_]),X=f.useMemo(()=>[...t.steps].sort((V,he)=>V.ordem-he.ordem),[t.steps]),te=X.length,Y=te>0?X[Math.min(j,te-1)]:null,Ke=f.useMemo(()=>Y?fn(Y,T,c):{},[Y,T,de]),Ne=f.useMemo(()=>({uploadFile:d,deleteUploadedFile:L?le:void 0,cepLookup:m,resolveTermsUploadUrl:E?se:void 0,externalData:c,fieldResolvers:p,validatorMapper:b,fieldWarnings:ee,componentMapper:F,paymentMethodOptions:C,onUploadStart:M,onUploadEnd:oe}),[d,L,le,m,se,E,p,b,ee,F,C,M,oe,de]),ut=f.useCallback(async V=>{if(!S){N(!0),$(null);try{const{cleaned:he,fileIdsToDelete:Be}=h.stripHiddenFields(Y,V,c);Be.length&&l&&await Promise.allSettled(Be.map(Re=>l(Re)));const ft={...T,...he};if(B(ft),s&&await s(j,he),j===te-1)i&&await i(ft);else{const Re=j+1;O(Re),D(xr=>Math.max(xr,Re))}}catch(he){console.error("[FormRenderer] Submit error:",he);const Be=he instanceof Error?he.message:"Ocorreu um erro. Tente novamente.";$(Be)}finally{N(!1)}}},[j,T,S,te,s,i,Y,c,l]),mt=f.useCallback(()=>{j>0&&O(V=>V-1)},[j]);if(!Y)return n.jsx(Me.Provider,{value:Ne,children:n.jsx(Se.TemplateProvider,{config:Z,className:`min-h-dvh ${Z.wrapperClass??""} ${y??""}`,renderWrapper:!0,children:n.jsx("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6 text-center text-muted-foreground",children:"Nenhum step configurado."})})});const xt=Z.layout.eventTitleStyle??"bar",mr=(Z.layout.stepIndicatorOrientation??"horizontal")==="vertical",Ie=te>=1?n.jsx(g,{steps:X.map(V=>({id:V.id,label:V.titulo,icone:V.icone})),currentStep:j,onStepClick:V=>{!z&&V!==j&&V<=k&&O(V)}}):null;return n.jsx(Me.Provider,{value:Ne,children:n.jsx(Se.TemplateProvider,{config:Z,className:`min-h-dvh ${Z.wrapperClass??""} ${y??""}`,renderWrapper:!0,children:n.jsxs("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6",children:[o&&xt==="bar"&&n.jsx("div",{className:"w-full text-center text-sm font-medium py-2.5 px-4 mb-6 rounded-lg border border-input text-muted-foreground bg-muted/30",children:o}),o&&xt==="inline"&&n.jsxs("div",{className:"text-center mb-6",children:[n.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-1",style:{color:"var(--t-text-muted)"},children:"Inscrição"}),n.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:o}),n.jsx("div",{className:"h-0.5 w-12 mx-auto mt-3 rounded-full",style:{background:"var(--t-primary)"}})]}),mr?n.jsxs("div",{className:"flex gap-6 items-start",children:[n.jsx("div",{className:"hidden sm:block shrink-0 w-44 pt-1",children:Ie}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"sm:hidden mb-6",children:Ie}),n.jsx($t,{stepIndex:j,totalSteps:te,step:Y,defaultValues:Ke,externalData:c,fieldErrors:u,isSubmitting:S,isUploading:z,submitError:P,validatorMapper:b,onWarningsChange:U,onValuesChange:v,onSubmit:ut,onBack:mt},j)]})]}):n.jsxs(n.Fragment,{children:[Ie&&n.jsx("div",{className:"mb-8",children:Ie}),n.jsx($t,{stepIndex:j,totalSteps:te,step:Y,defaultValues:Ke,externalData:c,fieldErrors:u,isSubmitting:S,isUploading:z,submitError:P,validatorMapper:b,onWarningsChange:U,onValuesChange:v,onSubmit:ut,onBack:mt},j)]})]})})})},hn=({children:t,render:e,onChange:r})=>{const s=lr(),i=f.useRef(r);return i.current=r,f.useEffect(()=>{var a;(a=i.current)==null||a.call(i,s)},[s.values,s.dirty,s.valid,s.submitting,s.errors,s.warnings]),e?n.jsx(n.Fragment,{children:e(s)}):typeof t=="function"?n.jsx(n.Fragment,{children:t(s)}):t!==void 0?n.jsx(n.Fragment,{children:t}):null};Object.defineProperty(exports,"evaluateFieldCondition",{enumerable:!0,get:()=>h.evaluateFieldCondition});exports.ContainerRenderer=or;exports.DFCepField=dt;exports.DFCheckbox=Ze;exports.DFCheckboxGroup=st;exports.DFDateField=Fe;exports.DFFieldArray=Jt;exports.DFFileUpload=lt;exports.DFHidden=Ge;exports.DFMaskedInput=be;exports.DFParticipationType=Qt;exports.DFPaymentMethod=rr;exports.DFRadioGroup=nt;exports.DFSelect=qe;exports.DFTerms=sr;exports.DFTextField=ne;exports.DFTextarea=We;exports.DefaultStepIndicator=ur;exports.FormRenderer=pn;exports.FormSpy=hn;exports.OPCOES_POR_DIA=er;exports.OPCOES_TODOS_OS_DIAS=tr;exports.RendererContext=Me;exports.StepRenderer=cr;exports.interpolate=Q;exports.interpolateContainer=Ve;exports.interpolateField=Vt;exports.interpolateStep=Wt;exports.makeStepResolver=Ut;exports.makeStepWarnComputer=_t;exports.useField=ln;exports.useFieldApi=dn;exports.useFormApi=cn;exports.useFormState=lr;exports.useRendererContext=pe;