@streamline-pulse/formkrafter-wc 0.14.0 → 0.15.1

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.
Files changed (38) hide show
  1. package/dist/components/fk-brick-actions.js +1 -1
  2. package/dist/components/fk-brick-list.js +1 -1
  3. package/dist/components/fk-brick-mold-item.js +1 -1
  4. package/dist/components/fk-brick-render.js +1 -1
  5. package/dist/components/fk-data-grid.js +1 -1
  6. package/dist/components/fk-drop-area.js +1 -1
  7. package/dist/components/fk-empty-form.js +1 -1
  8. package/dist/components/fk-file-input.js +1 -1
  9. package/dist/components/fk-form-builder.js +1 -1
  10. package/dist/components/fk-form-render.js +1 -1
  11. package/dist/components/fk-property-panel.js +1 -1
  12. package/dist/components/fk-rules-editor.js +1 -1
  13. package/dist/components/fk-select-input.js +1 -1
  14. package/dist/components/fk-signature-input.js +1 -1
  15. package/dist/components/fk-stepper.js +1 -1
  16. package/dist/components/fk-tabs.js +1 -1
  17. package/dist/components/index.js +1 -1
  18. package/dist/components/{p-H9MXQEyO.js → p-BX32u7uA.js} +1 -1
  19. package/dist/components/{p-Dz-U6j8q.js → p-Br0Vx2OJ.js} +1 -1
  20. package/dist/components/{p-DBDKSYBE.js → p-C2rZGevS.js} +1 -1
  21. package/dist/components/{p-DR_hFYe6.js → p-C3e5aB-B.js} +1 -1
  22. package/dist/components/{p-DjCHGcK-.js → p-C7zXpRR-.js} +1 -1
  23. package/dist/components/{p-DbuOohkN.js → p-CTNbGYU-.js} +1 -1
  24. package/dist/components/{p-1uIWCEFX.js → p-CaBKn69O.js} +1 -1
  25. package/dist/components/{p-BZtRpjkI.js → p-Co19MZSe.js} +1 -1
  26. package/dist/components/{p-heCFCh4Y.js → p-DTaQGwn6.js} +1 -1
  27. package/dist/components/{p-BCKF50Wl.js → p-DasHI1iN.js} +1 -1
  28. package/dist/components/{p-C2BQJ4lG.js → p-DdOwf47j.js} +1 -1
  29. package/dist/components/{p-CG5_blV_.js → p-EvvVwq09.js} +1 -1
  30. package/dist/components/{p-BQNLm3VZ.js → p-R4T2mo2A.js} +1 -1
  31. package/dist/components/{p-Cw0gv37q.js → p-ivyJWmcj.js} +1 -1
  32. package/dist/components/{p-jQ1X1HyU.js → p-qWT7cYoF.js} +1 -1
  33. package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
  34. package/dist/formkrafter-wc/index.esm.js +1 -1
  35. package/dist/formkrafter-wc/{p-1e48d41c.entry.js → p-506ba5dc.entry.js} +1 -1
  36. package/dist/formkrafter-wc/{p-f360c57a.entry.js → p-6a794e67.entry.js} +1 -1
  37. package/dist/formkrafter-wc/{p-C0wG_mBb.js → p-Du9ei1LL.js} +1 -1
  38. package/package.json +1 -1
@@ -9,4 +9,4 @@ function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"de
9
9
  * https://github.com/Starcounter-Jack/JSON-Patch
10
10
  * (c) 2017-2021 Joachim Wester
11
11
  * MIT license
12
- */function ws(t,e){e.unobserve()}function bs(t,e){var i,r=function(t){return ys.get(t)}(t);if(r){var n=function(t,e){return t.observers.get(e)}(r,e);i=n&&n.observer}else r=new gs(t),ys.set(t,r);if(i)return i;if(i={},r.value=Xn(t),e){i.callback=e,i.next=null;var s=function(){_s(i)},o=function(){clearTimeout(i.next),i.next=setTimeout(s)};"undefined"!=typeof window&&(window.addEventListener("mouseup",o),window.addEventListener("keyup",o),window.addEventListener("mousedown",o),window.addEventListener("keydown",o),window.addEventListener("change",o))}return i.patches=[],i.object=t,i.unobserve=function(){_s(i),clearTimeout(i.next),function(t,e){t.observers.delete(e.callback)}(r,i),"undefined"!=typeof window&&(window.removeEventListener("mouseup",o),window.removeEventListener("keyup",o),window.removeEventListener("mousedown",o),window.removeEventListener("keydown",o),window.removeEventListener("change",o))},r.observers.set(e,new $s(e,i)),i}function _s(t,e){void 0===e&&(e=!1);var i=ys.get(t.object);Es(i.value,t.object,t.patches,"",e),t.patches.length&&fs(i.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Es(t,e,i,r,n){if(e!==t){"function"==typeof e.toJSON&&(e=e.toJSON());for(var s=Qn(e),o=Qn(t),a=!1,h=o.length-1;h>=0;h--){var u=t[f=o[h]];if(!Yn(e,f)||void 0===e[f]&&void 0!==u&&!1===Array.isArray(e))Array.isArray(t)===Array.isArray(e)?(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"remove",path:r+"/"+es(f)}),a=!0):(n&&i.push({op:"test",path:r,value:t}),i.push({op:"replace",path:r,value:e}));else{var c=e[f];"object"==typeof u&&null!=u&&"object"==typeof c&&null!=c&&Array.isArray(u)===Array.isArray(c)?Es(u,c,i,r+"/"+es(f),n):u!==c&&(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"replace",path:r+"/"+es(f),value:Xn(c)}))}}if(a||s.length!=o.length)for(h=0;h<s.length;h++){var f;Yn(t,f=s[h])||void 0===e[f]||i.push({op:"add",path:r+"/"+es(f),value:Xn(e[f])})}}}function ks(t,e,i){void 0===i&&(i=!1);var r=[];return Es(t,e,r,"",i),r}var Ss=Object.assign({},vs,Object.freeze({__proto__:null,compare:ks,generate:_s,observe:bs,unobserve:ws}),{JsonPatchError:ss,deepClone:Xn,escapePathComponent:es,unescapePathComponent:is}),xs=Object.freeze({__proto__:null,JsonPatchError:ss,_areEquals:ms,applyOperation:cs,applyPatch:fs,applyReducer:ls,compare:ks,deepClone:Xn,default:Ss,escapePathComponent:es,generate:_s,getValueByPointer:us,observe:bs,unescapePathComponent:is,unobserve:ws,validate:ps,validator:ds});function Os(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&Object.keys(t).length>0&&Object.values(t).every((t=>"string"==typeof t))}function js(t,e){return Os(t)?e&&void 0!==t[e]?t[e]:Object.values(t)[0]:t}function Ps(t,e){if(!t)return t;const i={};for(const[r,n]of Object.entries(t))i[r]=js(n,e);return i}var Is={en:{required:"This field is required",minLength:"Must be at least {value} characters",maxLength:"Must be at most {value} characters",min:"Must be at least {value}",max:"Must be at most {value}",pattern:"Invalid format",minItems:"Select at least {value} item(s)",maxItems:"Select at most {value} item(s)",email:"Invalid email address",url:"Invalid URL",type:"Invalid value",custom:"Invalid value"},fr:{required:"Ce champ est obligatoire",minLength:"Minimum {value} caractères",maxLength:"Maximum {value} caractères",min:"Minimum {value}",max:"Maximum {value}",pattern:"Format invalide",minItems:"Sélectionnez au moins {value} élément(s)",maxItems:"Sélectionnez au plus {value} élément(s)",email:"Adresse email invalide",url:"URL invalide",type:"Valeur invalide",custom:"Valeur invalide"}};function Cs(t,e,i){return((Is[e??"en"]??Is.en)[t]??Is.en[t]??"Invalid value").replace("{value}",String(i??""))}function*As(t,e="0"){if(t){yield{brick:t,path:e};for(const[i,r]of(t.children??[]).entries())yield*As(r,`${e}.${i}`)}}function*Ns(t){if(t&&(yield t,"collection"!==t.type))for(const e of t.children??[])yield*Ns(e)}function Ts(t,e){if(t.configs?.key&&e)return t.unWrapData?e:e[t.configs.key]}function Ms(t,e){if(t.configs?.key)return t.unWrapData?e:{[t.configs.key]:e}}var Rs=(t,e)=>{if(!e.includes("."))return t[e];let i=t;for(const t of e.split(".")){if("object"!=typeof i||null===i)return;i=i[t]}return i};function Ds(t,e="label",i="value"){return Array.isArray(t)?t.map((t=>{if("object"==typeof t&&null!==t){const r=t,n=Rs(r,e)??Rs(r,i),s=Rs(r,i)??Rs(r,e);return{label:String(n??""),value:String(s??"")}}return{label:String(t),value:String(t)}})).filter((t=>""!==t.label)):String(t??"").split("\n").map((t=>t.trim())).filter(Boolean).map((t=>({label:t,value:t})))}var Ls={"palette.search":"Search bricks…","palette.empty":"No brick matches “{query}”","builder.undo":"Undo","builder.redo":"Redo","builder.editLocale":"Editing language","builder.copyJson":"Copy JSON","builder.importJson":"Import JSON","builder.importInvalid":"Invalid form JSON","builder.pasteHint":"Press Ctrl+V to paste a spec","builder.copied":"Copied!","builder.downloadJson":"Download .json","builder.hint":"Select a brick to edit its properties","drop.hint":"Drop a brick here","empty.title":"Your form is empty","empty.hint":"Drag a brick from the palette to get started","actions.move":"Move","actions.duplicate":"Duplicate","actions.delete":"Delete","stepper.back":"← Back","stepper.next":"Next →","stepper.submit":"Submit","panel.cfg.validateSteps":"Validate each step","panel.cfg.allowStepClick":"Allow clicking steps to jump","panel.cfg.showSubmit":"Submit button on last step","panel.cfg.validateTabs":"Validate tab before leaving it","signature.clear":"Clear","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Rules","panel.key":"Key","panel.label":"Label","panel.placeholder":"Placeholder","panel.prefix":"Prefix","panel.suffix":"Suffix","panel.accept":"Accepted file types","panel.mask":"Input mask (9=digit, a=letter, *=any)","panel.uploadUrl":"Upload URL","panel.cfg.multiple":"Allow multiple files","panel.optionsSource":"Options source","panel.options":"Options (one per line)","panel.content":"Content","panel.dataKey":"Data key","panel.url":"URL","panel.headers":"Headers ({token} reads form data)","panel.searchParam":"Server search param","panel.labelKey":"Label key","panel.valueKey":"Value key","panel.errorMessage":"Error message","panel.required":"Required","panel.minLength":"Min length","panel.maxLength":"Max length","panel.min":"Min","panel.max":"Max","panel.pattern":"Pattern (regex)","panel.minItems":"Min items","panel.maxItems":"Max items","panel.emailFormat":"Email format","panel.urlFormat":"URL format","panel.custom":"Custom (JavaScript)","panel.fallbackMessage":"Fallback message","panel.styleProperty":"property","panel.styleValue":"value","file.choose":"Choose a file…","file.uploading":"Uploading…","file.remove":"Remove file","file.addAnother":"+ Add a file","address.street":"Street","address.city":"City","address.zip":"Postal code","address.country":"Country","grid.addRow":"+ Add row","grid.moveUp":"Move row up","grid.moveDown":"Move row down","grid.removeRow":"Remove row","grid.empty":"No rows yet","grid.columns":"Row template","select.search":"Search…","select.empty":"No options","select.clear":"Clear","rules.when":"When","rules.then":"Then","rules.addRule":"+ Add rule","rules.addEffect":"+ Effect","rules.removeRule":"Remove rule","rules.removeEffect":"Remove effect","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Inputs","category.Layout":"Layout","category.Data":"Data","brick.text.name":"Text","brick.email.name":"Email","brick.password.name":"Password","brick.url.name":"URL","brick.phone.name":"Phone","brick.textarea.name":"Text area","brick.number.name":"Number","brick.date.name":"Date","brick.time.name":"Time","brick.datetime.name":"Date / Time","brick.select.name":"Select","brick.multi-select.name":"Multi select","brick.radio.name":"Radio","brick.select-boxes.name":"Select boxes","brick.checkbox.name":"Checkbox","brick.tags.name":"Tags","brick.signature.name":"Signature","brick.data-grid.name":"Data grid","brick.address.name":"Address","brick.file.name":"File","brick.hidden.name":"Hidden","brick.content.name":"Content","brick.recap.name":"Recap","brick.nested-form.name":"Nested form","brick.code.name":"Code","nestedForm.ref":"Referenced form","nestedForm.missing":"Set the specRef config to reference a form.","nestedForm.loading":"Loading nested forms…","panel.specRef":"Referenced form (specRef)","panel.optionsRef":"Options catalog (optionsRef)","recap.empty":"Nothing to summarize yet.","recap.yes":"Yes","recap.no":"No","panel.cfg.showEmpty":"Show empty fields","panel.cfg.groupBySections":"Group by section","brick.group.name":"Group","brick.row.name":"Row","brick.column.name":"Column","brick.stepper.name":"Stepper","brick.tabs.name":"Tabs"},zs={"palette.search":"Rechercher une brique…","palette.empty":"Aucune brique ne correspond à « {query} »","builder.undo":"Annuler","builder.editLocale":"Langue d'édition","builder.redo":"Rétablir","builder.copyJson":"Copier le JSON","builder.importJson":"Importer le JSON","builder.importInvalid":"JSON de formulaire invalide","builder.pasteHint":"Collez avec Ctrl+V pour importer une spec","builder.copied":"Copié !","builder.downloadJson":"Télécharger le .json","builder.hint":"Sélectionnez une brique pour éditer ses propriétés","drop.hint":"Déposez une brique ici","empty.title":"Votre formulaire est vide","empty.hint":"Glissez une brique depuis la palette pour commencer","actions.move":"Déplacer","actions.duplicate":"Dupliquer","actions.delete":"Supprimer","stepper.back":"← Précédent","stepper.next":"Suivant →","stepper.submit":"Envoyer","panel.cfg.validateSteps":"Valider chaque étape","panel.cfg.allowStepClick":"Autoriser le saut d’étapes au clic","panel.cfg.showSubmit":"Bouton d’envoi à la dernière étape","panel.cfg.validateTabs":"Valider l’onglet avant de le quitter","signature.clear":"Effacer","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Règles","panel.key":"Clé","panel.label":"Libellé","panel.placeholder":"Placeholder","panel.prefix":"Préfixe","panel.suffix":"Suffixe","panel.accept":"Types de fichiers acceptés","panel.mask":"Masque de saisie (9=chiffre, a=lettre, *=tout)","panel.uploadUrl":"URL d'upload","panel.cfg.multiple":"Autoriser plusieurs fichiers","panel.optionsSource":"Source des options","panel.options":"Options (une par ligne)","panel.content":"Contenu","panel.dataKey":"Clé de données","panel.url":"URL","panel.headers":"En-têtes ({token} lit les données du formulaire)","panel.searchParam":"Paramètre de recherche serveur","panel.labelKey":"Clé du libellé","panel.valueKey":"Clé de la valeur","panel.errorMessage":"Message d'erreur","panel.required":"Obligatoire","panel.minLength":"Longueur min","panel.maxLength":"Longueur max","panel.min":"Min","panel.max":"Max","panel.pattern":"Motif (regex)","panel.minItems":"Éléments min","panel.maxItems":"Éléments max","panel.emailFormat":"Format email","panel.urlFormat":"Format URL","panel.custom":"Personnalisé (JavaScript)","panel.fallbackMessage":"Message par défaut","panel.styleProperty":"propriété","panel.styleValue":"valeur","file.choose":"Choisir un fichier…","file.uploading":"Envoi en cours…","file.remove":"Retirer le fichier","file.addAnother":"+ Ajouter un fichier","address.street":"Rue","address.city":"Ville","address.zip":"Code postal","address.country":"Pays","grid.addRow":"+ Ajouter une ligne","grid.moveUp":"Monter la ligne","grid.moveDown":"Descendre la ligne","grid.removeRow":"Supprimer la ligne","grid.empty":"Aucune ligne","grid.columns":"Modèle de ligne","select.search":"Rechercher…","select.empty":"Aucune option","select.clear":"Effacer","rules.when":"Quand","rules.then":"Alors","rules.addRule":"+ Ajouter une règle","rules.addEffect":"+ Effet","rules.removeRule":"Supprimer la règle","rules.removeEffect":"Supprimer l'effet","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Champs","category.Layout":"Mise en page","category.Data":"Données","brick.text.name":"Texte","brick.email.name":"Email","brick.password.name":"Mot de passe","brick.url.name":"URL","brick.phone.name":"Téléphone","brick.textarea.name":"Zone de texte","brick.number.name":"Nombre","brick.date.name":"Date","brick.time.name":"Heure","brick.datetime.name":"Date / Heure","brick.select.name":"Liste déroulante","brick.multi-select.name":"Sélection multiple","brick.radio.name":"Boutons radio","brick.select-boxes.name":"Cases à cocher","brick.checkbox.name":"Case à cocher","brick.tags.name":"Étiquettes","brick.signature.name":"Signature","brick.data-grid.name":"Grille de données","brick.address.name":"Adresse","brick.file.name":"Fichier","brick.hidden.name":"Caché","brick.content.name":"Contenu","brick.recap.name":"Récapitulatif","brick.nested-form.name":"Formulaire imbriqué","brick.code.name":"Code","nestedForm.ref":"Formulaire référencé","nestedForm.missing":"Renseignez la config specRef pour référencer un formulaire.","nestedForm.loading":"Chargement des formulaires imbriqués…","panel.specRef":"Formulaire référencé (specRef)","panel.optionsRef":"Catalogue d'options (optionsRef)","recap.empty":"Rien à récapituler pour le moment.","recap.yes":"Oui","recap.no":"Non","panel.cfg.showEmpty":"Afficher les champs vides","panel.cfg.groupBySections":"Regrouper par section","brick.group.name":"Groupe","brick.row.name":"Ligne","brick.column.name":"Colonne","brick.stepper.name":"Étapes","brick.tabs.name":"Onglets"},Us=Symbol.for("formkrafter.i18n"),qs=globalThis,Fs=qs[Us]??={current:{...Ls}};function Vs(t={}){Fs.current={...Ls,...t}}function Bs(t,e){let i=Fs.current[t]??t;for(const[t,r]of Object.entries(e??{}))i=i.replace(`{${t}}`,String(r));return i}function Gs(t,e){return Fs.current[t]??e}var Hs=new Set(["__proto__","constructor","prototype"]);class Ks{value;constructor(t){this.value=t}}var Js=(t,e,i)=>{t.scopes[t.scopes.length-1].set(e,i)},Ws=t=>{if("number"==typeof t)return t;const e=String(t);if(Hs.has(e))throw new Error(`Access to "${e}" is not allowed`);return e},Zs=(t,e)=>({object:Ys(t,e.object),prop:Ws(e.computed?Ys(t,e.property):e.property.name),optional:!0===e.optional}),Ys=(t,e)=>{if(++t.steps>1e5)throw new Error("Sandbox execution budget exceeded");switch(e.type){case"Program":case"BlockStatement":for(const i of e.body){const e=Ys(t,i);if(e instanceof Ks)return e}return;case"ReturnStatement":return new Ks(e.argument?Ys(t,e.argument):void 0);case"IfStatement":return Ys(t,e.test)?Ys(t,e.consequent):e.alternate?Ys(t,e.alternate):void 0;case"VariableDeclaration":for(const i of e.declarations){const e=i.id;if("Identifier"!==e.type)throw new Error("Only simple variable names are supported");Js(t,e.name,i.init?Ys(t,i.init):void 0)}return;case"ExpressionStatement":return void Ys(t,e.expression);case"Literal":return e.value;case"TemplateLiteral":{const i=e.expressions;let r="";return e.quasis.forEach(((e,n)=>{r+=e.value.cooked??"",n<i.length&&(r+=String(Ys(t,i[n])))})),r}case"Identifier":return((t,e)=>{for(let i=t.scopes.length-1;i>=0;i--)if(t.scopes[i].has(e))return t.scopes[i].get(e);throw new Error(`Unknown identifier "${e}"`)})(t,e.name);case"ThisExpression":return;case"ChainExpression":return Ys(t,e.expression);case"MemberExpression":return((t,e)=>{const{object:i,prop:r,optional:n}=Zs(t,e);if(null==i){if(n)return;throw new Error(`Cannot read "${String(r)}" of ${String(i)}`)}return i[r]})(t,e);case"CallExpression":{const i=e.callee,r=[];for(const i of e.arguments)if("SpreadElement"===i.type){const e=Ys(t,i.argument);Array.isArray(e)&&r.push(...e)}else r.push(Ys(t,i));if("MemberExpression"===i.type){const{object:n,prop:s,optional:o}=Zs(t,i);if(null==n){if(o||!0===e.optional)return;throw new Error(`Cannot call "${String(s)}" of ${String(n)}`)}const a=n[s];if("function"!=typeof a){if(!0===e.optional&&null==a)return;throw new Error(`"${String(s)}" is not a function`)}if(a===Function||a===eval)throw new Error("This function is not allowed");return a.apply(n,r)}const n=Ys(t,i);if("function"!=typeof n){if(!0===e.optional&&null==n)return;throw new Error("Value is not a function")}if(n===Function||n===eval)throw new Error("This function is not allowed");return n(...r)}case"ArrowFunctionExpression":{const i=e.params,r=e.body,n=[...t.scopes];return(...s)=>{const o=new Map;i.forEach(((t,e)=>{if("Identifier"!==t.type)throw new Error("Only simple parameters are supported");o.set(t.name,s[e])}));const a={steps:t.steps,scopes:[...n,o]},h=Ys(a,r);return t.steps=a.steps,h instanceof Ks?h.value:!0===e.expression?h:void 0}}case"BinaryExpression":{const i=Ys(t,e.left),r=Ys(t,e.right);switch(e.operator){case"===":return i===r;case"!==":return i!==r;case"==":return i==r;case"!=":return i!=r;case"<":return i<r;case"<=":return i<=r;case">":return i>r;case">=":return i>=r;case"+":return i+r;case"-":return i-r;case"*":return i*r;case"/":return i/r;case"%":return i%r;case"**":return i**r;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"LogicalExpression":{const i=Ys(t,e.left);switch(e.operator){case"&&":return i&&Ys(t,e.right);case"||":return i||Ys(t,e.right);case"??":return i??Ys(t,e.right);default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"UnaryExpression":{const i=Ys(t,e.argument);switch(e.operator){case"!":return!i;case"-":return-i;case"+":return+i;case"typeof":return typeof i;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"ConditionalExpression":return Ys(t,e.test)?Ys(t,e.consequent):Ys(t,e.alternate);case"AssignmentExpression":{const i=e.left;if("Identifier"!==i.type||"="!==e.operator)throw new Error("Only simple assignments are supported");const r=Ys(t,e.right);return((t,e,i)=>{for(let r=t.scopes.length-1;r>=0;r--)if(t.scopes[r].has(e))return void t.scopes[r].set(e,i);throw new Error(`Cannot assign to unknown identifier "${e}"`)})(t,i.name,r),r}case"ArrayExpression":{const i=[];for(const r of e.elements)if(r)if("SpreadElement"===r.type){const e=Ys(t,r.argument);Array.isArray(e)&&i.push(...e)}else i.push(Ys(t,r));return i}case"ObjectExpression":{const i={};for(const r of e.properties){if("SpreadElement"===r.type){const e=Ys(t,r.argument);if(e&&"object"==typeof e)for(const[t,r]of Object.entries(e))i[String(Ws(t))]=r;continue}const e=r.key,n=Ws(r.computed?Ys(t,e):"Identifier"===e.type?e.name:e.value);i[String(n)]=Ys(t,r.value)}return i}default:throw new Error(`Unsupported syntax: ${e.type}`)}},Qs={undefined:void 0,NaN:NaN,Infinity:1/0,Math,JSON,Number,String,Boolean,Array,Object,Date,parseInt,parseFloat,isNaN,isFinite};class Xs{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchSpec(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load spec "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}class to{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchOptions(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load options "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}var eo=Symbol.for("formkrafter.core.services"),io=globalThis,ro=io[eo]??={jsRunnerService:new class{validateJs(t,e={ecmaVersion:"latest",allowReturnOutsideFunction:!0}){try{return Yt(t,e),{valid:!0}}catch(t){return{valid:!1,error:t instanceof Error?t:new Error(String(t))}}}eval(t,e={}){return function(t,e={}){const i=Yt(t,{ecmaVersion:"latest",allowReturnOutsideFunction:!0}),r={steps:0,scopes:[new Map(Object.entries({...Qs,...e})),new Map]},n=Ys(r,i);return n instanceof Ks?n.value:void 0}(t,e)}},dataSourceService:new class{defaults;cache=new Map;constructor(t={}){this.defaults=t}fetchOptions(t,e){const i={...this.defaults.headers,...e?.headers},r={};Object.keys(i).length&&(r.headers=i),this.defaults.credentials&&(r.credentials=this.defaults.credentials);const n=`${t}|${JSON.stringify(r)}`;let s=this.cache.get(n);return s||(s=fetch(t,Object.keys(r).length?r:void 0).then((e=>{if(!e.ok)throw new Error(`Data source request failed (${e.status}): ${t}`);return e.json()})).then((e=>{if(!Array.isArray(e))throw new Error(`Data source did not return an array: ${t}`);return e})).catch((t=>{throw this.cache.delete(n),t})),this.cache.set(n,s)),s}},fileUploadService:new class{async upload(t){const e=globalThis.btoa;if(!e)throw new Error("No base64 encoder available");const i=new Uint8Array(await t.arrayBuffer());let r="";for(const t of i)r+=String.fromCharCode(t);return{name:t.name,type:t.type,size:t.size,url:`data:${t.type};base64,${e(r)}`}}},specSourceService:new Xs,optionSourceService:new to};ro.specSourceService??=new Xs,ro.optionSourceService??=new to;var no=(t,e)=>{try{return ro.jsRunnerService.eval(t,{dataMap:e??{}})}catch(t){return t instanceof Error?t:new Error(String(t))}},so=(t,e)=>((t,e)=>((t,e)=>t?.filter((t=>((t,e)=>"jsonLogic"===t.type?null!=t.logic&&!0===n.apply(t.logic,e):"javaScript"===t.type&&!!t.code&&!0===no(t.code,e))(t,e))))(t,e)?.map((t=>t.effects)).flat().filter((t=>null!=t)))(t,e)?.map((t=>{let i;return t.property?("boolean"===t.property.type?i=t.boolean:"logic"===t.property.type&&null!=t.logic?i=n.apply(t.logic,e):"code"===t.property.type&&t.code?i=no(t.code,e):"string"===t.property.type&&(i=t.string),{[t.property.target]:i}):{}})).flat().reduce(((t,e)=>({...t,...e})),{})??{hidden:!1},oo=(t,e)=>{if(Array.isArray(e))return e.map((e=>oo(t,e))).filter(Boolean).join(", ");if(!0===e)return Gs("recap.yes","Yes");if(!1===e)return Gs("recap.no","No");if(e&&"object"==typeof e)return"string"==typeof e.name&&"url"in e?e.name:Object.values(e).filter((t=>"string"==typeof t&&t)).join(" ");const i=String(e??"");if(null!=t.configs?.options){const e=Ds(t.configs.options,"string"==typeof t.configs.labelKey?t.configs.labelKey:"label","string"==typeof t.configs.valueKey?t.configs.valueKey:"value").find((t=>t.value===i));if(e)return e.label}return i},ao=t=>null==t||""===t||Array.isArray(t)&&0===t.length,ho=(t,e)=>String(js(t.configs?.label,e)??t.name??t.configs?.key??""),uo=t=>{const e=[];for(const i of t.children??[]){const t=i.configs?.key;"input"===i.type&&t&&!t.startsWith("_")&&e.push(i)}return e},co=(t,e,i,r,n=!1)=>{if(!t)return[];const s=[];for(const o of t.children??[]){if("recap"===o.id||"action"===o.type)continue;if(!0===so(o.rules,e).hidden)continue;const t=o.configs?.key,a=ho(o,i);if("collection"===o.type){const n=t&&Array.isArray(e?.[t])?e[t]:[];if(!n.length&&!r)continue;const h=uo(o);s.push({kind:"collection",label:a,columns:h.map((t=>ho(t,i))),rows:n.map((t=>h.map((e=>{const i=t?.[e.configs.key];return ao(i)?"—":oo(e,i)}))))});continue}if("panel"===o.type){const t=js(o.configs?.label,i);if(n&&"string"==typeof t&&t.trim()){const n=co(o,e,i,r);n.length&&(s.push({kind:"section",label:t}),s.push(...n));continue}s.push(...co(o,e,i,r,n));continue}if("input"!==o.type||!t||t.startsWith("_"))continue;const h=e?.[t];ao(h)&&!r||s.push({kind:"field",label:a,value:ao(h)?"—":oo(o,h)})}return s},fo=(t,e)=>{const i=e(t),r=t.children?.map((t=>fo(t,e)));if(i===t.configs&&r===t.children)return t;const n={...t};return void 0===i?delete n.configs:n.configs=i,r&&(n.children=r),n};function lo(t){return fo(t,(t=>t.configs?.uid?t.configs:{...t.configs,uid:crypto.randomUUID()}))}function po(t){return fo(t,(t=>{if(!t.configs||!("uid"in t.configs))return t.configs;const{uid:e,...i}=t.configs;return Object.keys(i).length>0?i:void 0}))}var mo=(t,e)=>Array.isArray(t)?t.map((t=>mo(t,e))):(t=>null!=t&&"object"==typeof t&&!Array.isArray(t)&&"string"==typeof t.type&&"string"==typeof t.id)(t)?po(t):e.endsWith("/configs")&&null!=t&&"object"==typeof t?(t=>{const{uid:e,...i}=t;return i})(t):t;function vo(t){return t.map((t=>"value"in t?{...t,value:mo(t.value,t.path)}:t))}function yo(t,e){return t.replace(/\{(\w+)\}/g,((t,i)=>{const r=e?.[i];return null==r?"":String(r)}))}function go(t,e){if("string"!=typeof t||!t.trim())return;const i={};for(const r of t.split("\n")){const t=r.indexOf(":");if(t<=0)continue;const n=r.slice(0,t).trim(),s=yo(r.slice(t+1).trim(),e);n&&(i[n]=s)}return Object.keys(i).length?i:void 0}function $o(t,e,i){if(!i)return t;const r=t.includes("?")?"&":"?";return`${t}${r}${encodeURIComponent(e)}=${encodeURIComponent(i)}`}class wo{type;dataType;id;name;configsForm;category;styles;unWrapData;isPrivate;validators;defaultConfigs;constructor(t){this.type=t.type,this.dataType=t.dataType,this.id=t.id,this.name=t.name,this.configsForm=t.configsForm,this.category=t.category,this.styles=t.styles,this.unWrapData=t.unWrapData??!1,this.isPrivate=t.isPrivate??!1,this.validators=t.validators??[],this.defaultConfigs=t.defaultConfigs}getBrickEmptySpec(){return{type:this.type,dataType:this.dataType,id:this.id,name:this.name,...void 0!==this.category?{category:this.category}:{},...void 0!==this.configsForm?{configsForm:this.configsForm}:{},...void 0!==this.styles?{styles:this.styles}:{},...void 0!==this.defaultConfigs?{configs:{...this.defaultConfigs}}:{},validators:this.validators}}}var bo=new Un.Ajv({allErrors:!0});Jn(bo,["email","uri"]),Vn(bo);var _o=new WeakMap,Eo=t=>{if("required"===t.keyword)return t.params.missingProperty;if("errorMessage"===t.keyword){const e=t.params.errors?.[0];return e?Eo(e):void 0}return t.instancePath.split("/").filter(Boolean)[0]},ko=(t,e,i)=>{const r={},n=((t,e)=>{let i=_o.get(t);i||(i=new Map,_o.set(t,i));const r=e??"";let n=i.get(r);if(!n){const s=function(t,e){if(!t)return;const i={},r=[],n={},s=t=>{const i=js(t,e);return"string"==typeof i?i:void 0};for(const o of Ns(t)){const t=o.configs?.key,a=!0===o.configs?.multiple&&"object"===o.dataType?"array":o.dataType;if(!t||!a||"void"===a)continue;const h=o.validations?.find((t=>"required"===t.validator)),u={type:a,nullable:!h},c={type:Cs("type",e)};for(const t of o.validations??[]){const{validator:i,value:r}=t,n=s(t.message)??Cs(i,e,r);"minLength"===i&&null!=r?(u.minLength=Number(r),c.minLength=n):"maxLength"===i&&null!=r?(u.maxLength=Number(r),c.maxLength=n):"min"===i&&null!=r?(u.minimum=Number(r),c.minimum=n):"max"===i&&null!=r?(u.maximum=Number(r),c.maximum=n):"pattern"===i&&"string"==typeof r&&r?(u.pattern=r,c.pattern=n):"minItems"===i&&null!=r?(u.minItems=Number(r),c.minItems=n):"maxItems"===i&&null!=r?(u.maxItems=Number(r),c.maxItems=n):"email"===i?(u.format="email",c.format=n):"url"===i&&(u.format="uri",c.format=n)}u.errorMessage=c,i[t]=u,h&&(r.push(t),n[t]=s(h.message)??Cs("required",e))}return{type:"object",properties:i,required:r,...Object.keys(n).length?{errorMessage:{required:n}}:{},additionalProperties:!1}}(t,e);if(!s)return;try{n=bo.compile(s)}catch{return}i.set(r,n)}return n})(t,i);if(n&&!n(e))for(const t of n.errors??[]){const e=Eo(t);e&&!(e in r)&&t.message&&(r[e]=t.message)}for(const[n,s]of Object.entries(((t,e,i)=>{const r={},n=e??{};for(const e of Ns(t)){const t=e.configs?.key;if(t)for(const s of e.validations??[]){if("custom"!==s.validator||!s.customValidator)continue;const e=no(`const value = dataMap?.[${JSON.stringify(t)}];\n${s.customValidator}`,n);if(!0!==e&&null!=e&&!(t in r))if("string"==typeof e)r[t]=e;else if(e instanceof Error)r[t]=e.message;else{const e=js(s.message,i);r[t]="string"==typeof e?e:Cs("custom",i)}}}return r})(t,e,i)))n in r||(r[n]=s);const s="object"==typeof e&&null!==e?e:void 0;for(const e of((t,e)=>{const i=new Set,r=(t,n)=>{const s=n||!!t.rules?.length&&!0===so(t.rules,e).hidden,o=t.configs?.key;if(s&&o&&i.add(o),"collection"!==t.type)for(const e of t.children??[])r(e,s)};return r(t,!1),i})(t,s))delete r[e];return{valid:0===Object.keys(r).length,errors:r}};function So(t){return t.split(".").slice(1).map((t=>`/children/${t}`)).join("")}function xo(t,e){if(t.configs?.uid===e)return"";for(const[i,r]of(t.children??[]).entries()){const t=xo(r,e);if(void 0!==t)return`/children/${i}${t}`}}function Oo(t,e){let i=t;for(const t of e.split(".").slice(1))i=i?.children?.[Number(t)];return i}var jo=(Ss??xs).applyPatch,Po=(t,e,i)=>({spec:jo(t,e,!0,!1).newDocument,patches:e,inverse:i}),Io=(t,e)=>{const i=Oo(t,e);if(!i)throw new Error(`No brick at path "${e}"`);return i},Co=(t,e)=>{const i=xo(t,e);if(void 0===i)throw new Error(`No brick with uid "${e}"`);let r=t;for(const t of i.split("/children/").slice(1))r=r.children[Number(t)];return{pointer:i,brick:r}},Ao=t=>JSON.parse(JSON.stringify(t));function No(t,e,i,r){const n=Io(t,i),s=So(i),o=Ao(e);if(!n.children){const e=`${s}/children`;return Po(t,[{op:"add",path:e,value:[o]}],[{op:"remove",path:e}])}const a=`${s}/children/${Math.min(r??n.children.length,n.children.length)}`;return Po(t,[{op:"add",path:a,value:o}],[{op:"remove",path:a}])}function To(t,e){if("0"===e)throw new Error("Cannot remove the root brick");const i=Io(t,e),r=So(e);return Po(t,[{op:"remove",path:r}],[{op:"add",path:r,value:i}])}function Mo(t,e,i){if("0"===e||"0"===i)throw new Error("Cannot move the root brick");const r=Io(t,e),n=e.split(".").map(Number),s=i.split(".").map(Number),o=n.length-1,a=n[o],h=s.length>o&&n.slice(0,o).every(((t,e)=>t===s[e])),u=[...s];if(h){if(u[o]===a&&u.length>n.length)throw new Error(`Cannot move a brick into its own subtree ("${e}" → "${i}")`);u[o]>a&&(u[o]-=1)}const c=So(e),f=So(u.join("."));return Po(t,[{op:"remove",path:c},{op:"add",path:f,value:r}],[{op:"remove",path:f},{op:"add",path:c,value:r}])}var Ro=t=>({...t,...t.configs?{configs:{...t.configs,uid:crypto.randomUUID()}}:{},...t.children?{children:t.children.map(Ro)}:{}});function Do(t,e){if("0"===e)throw new Error("Cannot duplicate the root brick");const i=Io(t,e),r=e.split("."),n=Number(r[r.length-1])+1,s=So([...r.slice(0,-1),String(n)].join(".")),o=Ro(Ao(i));return Po(t,[{op:"add",path:s,value:o}],[{op:"remove",path:s}])}var Lo=(t,e,i,r,n)=>{const s=`${e}/${i}`;return void 0===n?Po(t,[{op:"add",path:s,value:r}],[{op:"remove",path:s}]):Po(t,[{op:"replace",path:s,value:r}],[{op:"replace",path:s,value:n}])};function zo(t,e,i){const{pointer:r,brick:n}=Co(t,e),s={...n.configs,...i};return Lo(t,r,"configs",s,n.configs)}function Uo(t,e,i){const{pointer:r,brick:n}=Co(t,e),s={...n.styles,...i};return Lo(t,r,"styles",s,n.styles)}function qo(t,e,i){const{pointer:r,brick:n}=Co(t,e);return Lo(t,r,"validations",i,n.validations)}function Fo(t,e,i){const{pointer:r,brick:n}=Co(t,e);return Lo(t,r,"rules",i,n.rules)}class Vo{past=[];future=[];record(t){this.past.push({patches:t.patches,inverse:t.inverse}),this.future=[]}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}undo(t){const e=this.past.pop();if(e)return this.future.push(e),jo(t,e.inverse,!0,!1).newDocument}redo(t){const e=this.future.pop();if(e)return this.past.push(e),jo(t,e.patches,!0,!1).newDocument}clear(){this.past=[],this.future=[]}}var Bo=t=>"nested-form"===t.id&&"string"==typeof t.configs?.specRef,Go=t=>{if(!t)return!1;for(const{brick:e}of As(t))if(Bo(e)&&e.configs?.specRef)return!0;return!1};async function Ho(t,e={}){const i=e.specSourceService??ro.specSourceService,r=e.maxDepth??5,n=async(t,e)=>{if(Bo(t)&&t.configs?.specRef){const s=String(t.configs.specRef);if(e.includes(s))throw new Error(`Circular nested form reference: ${[...e,s].join(" → ")}`);if(e.length>=r)throw new Error(`Nested forms exceed the maximum depth of ${r} (${s})`);const o=await i.fetchSpec(s),a=await n(structuredClone(o),[...e,s]);return{type:"panel",id:"group",name:t.name,configs:{...t.configs,label:t.configs.label??a.name},styles:t.styles,rules:t.rules,children:a.children??[]}}return t.children?.length?{...t,children:await Promise.all(t.children.map((t=>n(t,e))))}:t};return n(structuredClone(t),[])}export{go as A,Ds as B,no as C,Ns as D,wo as E,co as F,js as G,Vs as H,zs as I,Vo as S,Gs as a,Ts as b,No as c,Oo as d,lo as e,Bs as f,so as g,To as h,Do as i,Uo as j,qo as k,Fo as l,Mo as m,As as n,vo as o,po as p,Go as q,Ps as r,ro as s,Ho as t,zo as u,ko as v,Ms as w,Os as x,yo as y,$o as z}
12
+ */function ws(t,e){e.unobserve()}function bs(t,e){var i,r=function(t){return ys.get(t)}(t);if(r){var n=function(t,e){return t.observers.get(e)}(r,e);i=n&&n.observer}else r=new gs(t),ys.set(t,r);if(i)return i;if(i={},r.value=Xn(t),e){i.callback=e,i.next=null;var s=function(){_s(i)},o=function(){clearTimeout(i.next),i.next=setTimeout(s)};"undefined"!=typeof window&&(window.addEventListener("mouseup",o),window.addEventListener("keyup",o),window.addEventListener("mousedown",o),window.addEventListener("keydown",o),window.addEventListener("change",o))}return i.patches=[],i.object=t,i.unobserve=function(){_s(i),clearTimeout(i.next),function(t,e){t.observers.delete(e.callback)}(r,i),"undefined"!=typeof window&&(window.removeEventListener("mouseup",o),window.removeEventListener("keyup",o),window.removeEventListener("mousedown",o),window.removeEventListener("keydown",o),window.removeEventListener("change",o))},r.observers.set(e,new $s(e,i)),i}function _s(t,e){void 0===e&&(e=!1);var i=ys.get(t.object);Es(i.value,t.object,t.patches,"",e),t.patches.length&&fs(i.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Es(t,e,i,r,n){if(e!==t){"function"==typeof e.toJSON&&(e=e.toJSON());for(var s=Qn(e),o=Qn(t),a=!1,h=o.length-1;h>=0;h--){var u=t[f=o[h]];if(!Yn(e,f)||void 0===e[f]&&void 0!==u&&!1===Array.isArray(e))Array.isArray(t)===Array.isArray(e)?(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"remove",path:r+"/"+es(f)}),a=!0):(n&&i.push({op:"test",path:r,value:t}),i.push({op:"replace",path:r,value:e}));else{var c=e[f];"object"==typeof u&&null!=u&&"object"==typeof c&&null!=c&&Array.isArray(u)===Array.isArray(c)?Es(u,c,i,r+"/"+es(f),n):u!==c&&(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"replace",path:r+"/"+es(f),value:Xn(c)}))}}if(a||s.length!=o.length)for(h=0;h<s.length;h++){var f;Yn(t,f=s[h])||void 0===e[f]||i.push({op:"add",path:r+"/"+es(f),value:Xn(e[f])})}}}function ks(t,e,i){void 0===i&&(i=!1);var r=[];return Es(t,e,r,"",i),r}var Ss=Object.assign({},vs,Object.freeze({__proto__:null,compare:ks,generate:_s,observe:bs,unobserve:ws}),{JsonPatchError:ss,deepClone:Xn,escapePathComponent:es,unescapePathComponent:is}),xs=Object.freeze({__proto__:null,JsonPatchError:ss,_areEquals:ms,applyOperation:cs,applyPatch:fs,applyReducer:ls,compare:ks,deepClone:Xn,default:Ss,escapePathComponent:es,generate:_s,getValueByPointer:us,observe:bs,unescapePathComponent:is,unobserve:ws,validate:ps,validator:ds});function Os(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&Object.keys(t).length>0&&Object.values(t).every((t=>"string"==typeof t))}function js(t,e){return Os(t)?e&&void 0!==t[e]?t[e]:Object.values(t)[0]:t}function Ps(t,e){if(!t)return t;const i={};for(const[r,n]of Object.entries(t))i[r]=js(n,e);return i}var Is={en:{required:"This field is required",minLength:"Must be at least {value} characters",maxLength:"Must be at most {value} characters",min:"Must be at least {value}",max:"Must be at most {value}",pattern:"Invalid format",minItems:"Select at least {value} item(s)",maxItems:"Select at most {value} item(s)",email:"Invalid email address",url:"Invalid URL",type:"Invalid value",custom:"Invalid value"},fr:{required:"Ce champ est obligatoire",minLength:"Minimum {value} caractères",maxLength:"Maximum {value} caractères",min:"Minimum {value}",max:"Maximum {value}",pattern:"Format invalide",minItems:"Sélectionnez au moins {value} élément(s)",maxItems:"Sélectionnez au plus {value} élément(s)",email:"Adresse email invalide",url:"URL invalide",type:"Valeur invalide",custom:"Valeur invalide"}};function Cs(t,e,i){return((Is[e??"en"]??Is.en)[t]??Is.en[t]??"Invalid value").replace("{value}",String(i??""))}function*As(t,e="0"){if(t){yield{brick:t,path:e};for(const[i,r]of(t.children??[]).entries())yield*As(r,`${e}.${i}`)}}function*Ns(t){if(t&&(yield t,"collection"!==t.type))for(const e of t.children??[])yield*Ns(e)}function Ts(t,e){if(t.configs?.key&&e)return t.unWrapData?e:e[t.configs.key]}function Ms(t,e){if(t.configs?.key)return t.unWrapData?e:{[t.configs.key]:e}}var Rs=(t,e)=>{if(!e.includes("."))return t[e];let i=t;for(const t of e.split(".")){if("object"!=typeof i||null===i)return;i=i[t]}return i};function Ds(t,e="label",i="value"){return Array.isArray(t)?t.map((t=>{if("object"==typeof t&&null!==t){const r=t,n=Rs(r,e)??Rs(r,i),s=Rs(r,i)??Rs(r,e);return{label:String(n??""),value:String(s??"")}}return{label:String(t),value:String(t)}})).filter((t=>""!==t.label)):String(t??"").split("\n").map((t=>t.trim())).filter(Boolean).map((t=>({label:t,value:t})))}var Ls={"palette.search":"Search bricks…","palette.empty":"No brick matches “{query}”","builder.undo":"Undo","builder.redo":"Redo","builder.editLocale":"Editing language","builder.copyJson":"Copy JSON","builder.importJson":"Import JSON","builder.importInvalid":"Invalid form JSON","builder.pasteHint":"Press Ctrl+V to paste a spec","builder.copied":"Copied!","builder.downloadJson":"Download .json","builder.hint":"Select a brick to edit its properties","drop.hint":"Drop a brick here","empty.title":"Your form is empty","empty.hint":"Drag a brick from the palette to get started","actions.move":"Move","actions.duplicate":"Duplicate","actions.delete":"Delete","stepper.back":"← Back","stepper.next":"Next →","stepper.submit":"Submit","panel.cfg.validateSteps":"Validate each step","panel.cfg.allowStepClick":"Allow clicking steps to jump","panel.cfg.showSubmit":"Submit button on last step","panel.cfg.validateTabs":"Validate tab before leaving it","signature.clear":"Clear","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Rules","panel.key":"Key","panel.label":"Label","panel.placeholder":"Placeholder","panel.prefix":"Prefix","panel.suffix":"Suffix","panel.accept":"Accepted file types","panel.mask":"Input mask (9=digit, a=letter, *=any)","panel.uploadUrl":"Upload URL","panel.cfg.multiple":"Allow multiple files","panel.optionsSource":"Options source","panel.options":"Options (one per line)","panel.content":"Content","panel.dataKey":"Data key","panel.url":"URL","panel.headers":"Headers ({token} reads form data)","panel.searchParam":"Server search param","panel.labelKey":"Label key","panel.valueKey":"Value key","panel.errorMessage":"Error message","panel.required":"Required","panel.minLength":"Min length","panel.maxLength":"Max length","panel.min":"Min","panel.max":"Max","panel.pattern":"Pattern (regex)","panel.minItems":"Min items","panel.maxItems":"Max items","panel.emailFormat":"Email format","panel.urlFormat":"URL format","panel.custom":"Custom (JavaScript)","panel.fallbackMessage":"Fallback message","panel.styleProperty":"property","panel.styleValue":"value","file.choose":"Choose a file…","file.uploading":"Uploading…","file.remove":"Remove file","file.addAnother":"+ Add a file","address.street":"Street","address.city":"City","address.zip":"Postal code","address.country":"Country","grid.addRow":"+ Add row","grid.moveUp":"Move row up","grid.moveDown":"Move row down","grid.removeRow":"Remove row","grid.empty":"No rows yet","grid.columns":"Row template","select.search":"Search…","select.empty":"No options","select.clear":"Clear","rules.when":"When","rules.then":"Then","rules.addRule":"+ Add rule","rules.addEffect":"+ Effect","rules.removeRule":"Remove rule","rules.removeEffect":"Remove effect","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Inputs","category.Layout":"Layout","category.Data":"Data","brick.text.name":"Text","brick.email.name":"Email","brick.password.name":"Password","brick.url.name":"URL","brick.phone.name":"Phone","brick.textarea.name":"Text area","brick.number.name":"Number","brick.date.name":"Date","brick.time.name":"Time","brick.datetime.name":"Date / Time","brick.select.name":"Select","brick.multi-select.name":"Multi select","brick.radio.name":"Radio","brick.select-boxes.name":"Select boxes","brick.checkbox.name":"Checkbox","brick.tags.name":"Tags","brick.signature.name":"Signature","brick.data-grid.name":"Data grid","brick.address.name":"Address","brick.file.name":"File","brick.hidden.name":"Hidden","brick.content.name":"Content","brick.recap.name":"Recap","brick.nested-form.name":"Nested form","brick.code.name":"Code","nestedForm.ref":"Referenced form","nestedForm.missing":"Set the specRef config to reference a form.","nestedForm.loading":"Loading nested forms…","panel.specRef":"Referenced form (specRef)","panel.optionsRef":"Options catalog (optionsRef)","recap.empty":"Nothing to summarize yet.","recap.yes":"Yes","recap.no":"No","panel.cfg.showEmpty":"Show empty fields","panel.cfg.groupBySections":"Group by section","brick.group.name":"Group","brick.row.name":"Row","brick.column.name":"Column","brick.stepper.name":"Stepper","brick.tabs.name":"Tabs"},zs={"palette.search":"Rechercher une brique…","palette.empty":"Aucune brique ne correspond à « {query} »","builder.undo":"Annuler","builder.editLocale":"Langue d'édition","builder.redo":"Rétablir","builder.copyJson":"Copier le JSON","builder.importJson":"Importer le JSON","builder.importInvalid":"JSON de formulaire invalide","builder.pasteHint":"Collez avec Ctrl+V pour importer une spec","builder.copied":"Copié !","builder.downloadJson":"Télécharger le .json","builder.hint":"Sélectionnez une brique pour éditer ses propriétés","drop.hint":"Déposez une brique ici","empty.title":"Votre formulaire est vide","empty.hint":"Glissez une brique depuis la palette pour commencer","actions.move":"Déplacer","actions.duplicate":"Dupliquer","actions.delete":"Supprimer","stepper.back":"← Précédent","stepper.next":"Suivant →","stepper.submit":"Envoyer","panel.cfg.validateSteps":"Valider chaque étape","panel.cfg.allowStepClick":"Autoriser le saut d’étapes au clic","panel.cfg.showSubmit":"Bouton d’envoi à la dernière étape","panel.cfg.validateTabs":"Valider l’onglet avant de le quitter","signature.clear":"Effacer","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Règles","panel.key":"Clé","panel.label":"Libellé","panel.placeholder":"Placeholder","panel.prefix":"Préfixe","panel.suffix":"Suffixe","panel.accept":"Types de fichiers acceptés","panel.mask":"Masque de saisie (9=chiffre, a=lettre, *=tout)","panel.uploadUrl":"URL d'upload","panel.cfg.multiple":"Autoriser plusieurs fichiers","panel.optionsSource":"Source des options","panel.options":"Options (une par ligne)","panel.content":"Contenu","panel.dataKey":"Clé de données","panel.url":"URL","panel.headers":"En-têtes ({token} lit les données du formulaire)","panel.searchParam":"Paramètre de recherche serveur","panel.labelKey":"Clé du libellé","panel.valueKey":"Clé de la valeur","panel.errorMessage":"Message d'erreur","panel.required":"Obligatoire","panel.minLength":"Longueur min","panel.maxLength":"Longueur max","panel.min":"Min","panel.max":"Max","panel.pattern":"Motif (regex)","panel.minItems":"Éléments min","panel.maxItems":"Éléments max","panel.emailFormat":"Format email","panel.urlFormat":"Format URL","panel.custom":"Personnalisé (JavaScript)","panel.fallbackMessage":"Message par défaut","panel.styleProperty":"propriété","panel.styleValue":"valeur","file.choose":"Choisir un fichier…","file.uploading":"Envoi en cours…","file.remove":"Retirer le fichier","file.addAnother":"+ Ajouter un fichier","address.street":"Rue","address.city":"Ville","address.zip":"Code postal","address.country":"Pays","grid.addRow":"+ Ajouter une ligne","grid.moveUp":"Monter la ligne","grid.moveDown":"Descendre la ligne","grid.removeRow":"Supprimer la ligne","grid.empty":"Aucune ligne","grid.columns":"Modèle de ligne","select.search":"Rechercher…","select.empty":"Aucune option","select.clear":"Effacer","rules.when":"Quand","rules.then":"Alors","rules.addRule":"+ Ajouter une règle","rules.addEffect":"+ Effet","rules.removeRule":"Supprimer la règle","rules.removeEffect":"Supprimer l'effet","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Champs","category.Layout":"Mise en page","category.Data":"Données","brick.text.name":"Texte","brick.email.name":"Email","brick.password.name":"Mot de passe","brick.url.name":"URL","brick.phone.name":"Téléphone","brick.textarea.name":"Zone de texte","brick.number.name":"Nombre","brick.date.name":"Date","brick.time.name":"Heure","brick.datetime.name":"Date / Heure","brick.select.name":"Liste déroulante","brick.multi-select.name":"Sélection multiple","brick.radio.name":"Boutons radio","brick.select-boxes.name":"Cases à cocher","brick.checkbox.name":"Case à cocher","brick.tags.name":"Étiquettes","brick.signature.name":"Signature","brick.data-grid.name":"Grille de données","brick.address.name":"Adresse","brick.file.name":"Fichier","brick.hidden.name":"Caché","brick.content.name":"Contenu","brick.recap.name":"Récapitulatif","brick.nested-form.name":"Formulaire imbriqué","brick.code.name":"Code","nestedForm.ref":"Formulaire référencé","nestedForm.missing":"Renseignez la config specRef pour référencer un formulaire.","nestedForm.loading":"Chargement des formulaires imbriqués…","panel.specRef":"Formulaire référencé (specRef)","panel.optionsRef":"Catalogue d'options (optionsRef)","recap.empty":"Rien à récapituler pour le moment.","recap.yes":"Oui","recap.no":"Non","panel.cfg.showEmpty":"Afficher les champs vides","panel.cfg.groupBySections":"Regrouper par section","brick.group.name":"Groupe","brick.row.name":"Ligne","brick.column.name":"Colonne","brick.stepper.name":"Étapes","brick.tabs.name":"Onglets"},Us=Symbol.for("formkrafter.i18n"),qs=globalThis,Fs=qs[Us]??={current:{...Ls}};function Vs(t={}){Fs.current={...Ls,...t}}function Bs(t,e){let i=Fs.current[t]??t;for(const[t,r]of Object.entries(e??{}))i=i.replace(`{${t}}`,String(r));return i}function Gs(t,e){return Fs.current[t]??e}var Hs=new Set(["__proto__","constructor","prototype"]);class Ks{value;constructor(t){this.value=t}}var Js=(t,e,i)=>{t.scopes[t.scopes.length-1].set(e,i)},Ws=t=>{if("number"==typeof t)return t;const e=String(t);if(Hs.has(e))throw new Error(`Access to "${e}" is not allowed`);return e},Zs=(t,e)=>({object:Ys(t,e.object),prop:Ws(e.computed?Ys(t,e.property):e.property.name),optional:!0===e.optional}),Ys=(t,e)=>{if(++t.steps>1e5)throw new Error("Sandbox execution budget exceeded");switch(e.type){case"Program":case"BlockStatement":for(const i of e.body){const e=Ys(t,i);if(e instanceof Ks)return e}return;case"ReturnStatement":return new Ks(e.argument?Ys(t,e.argument):void 0);case"IfStatement":return Ys(t,e.test)?Ys(t,e.consequent):e.alternate?Ys(t,e.alternate):void 0;case"VariableDeclaration":for(const i of e.declarations){const e=i.id;if("Identifier"!==e.type)throw new Error("Only simple variable names are supported");Js(t,e.name,i.init?Ys(t,i.init):void 0)}return;case"ExpressionStatement":return void Ys(t,e.expression);case"Literal":return e.value;case"TemplateLiteral":{const i=e.expressions;let r="";return e.quasis.forEach(((e,n)=>{r+=e.value.cooked??"",n<i.length&&(r+=String(Ys(t,i[n])))})),r}case"Identifier":return((t,e)=>{for(let i=t.scopes.length-1;i>=0;i--)if(t.scopes[i].has(e))return t.scopes[i].get(e);throw new Error(`Unknown identifier "${e}"`)})(t,e.name);case"ThisExpression":return;case"ChainExpression":return Ys(t,e.expression);case"MemberExpression":return((t,e)=>{const{object:i,prop:r,optional:n}=Zs(t,e);if(null==i){if(n)return;throw new Error(`Cannot read "${String(r)}" of ${String(i)}`)}return i[r]})(t,e);case"CallExpression":{const i=e.callee,r=[];for(const i of e.arguments)if("SpreadElement"===i.type){const e=Ys(t,i.argument);Array.isArray(e)&&r.push(...e)}else r.push(Ys(t,i));if("MemberExpression"===i.type){const{object:n,prop:s,optional:o}=Zs(t,i);if(null==n){if(o||!0===e.optional)return;throw new Error(`Cannot call "${String(s)}" of ${String(n)}`)}const a=n[s];if("function"!=typeof a){if(!0===e.optional&&null==a)return;throw new Error(`"${String(s)}" is not a function`)}if(a===Function||a===eval)throw new Error("This function is not allowed");return a.apply(n,r)}const n=Ys(t,i);if("function"!=typeof n){if(!0===e.optional&&null==n)return;throw new Error("Value is not a function")}if(n===Function||n===eval)throw new Error("This function is not allowed");return n(...r)}case"ArrowFunctionExpression":{const i=e.params,r=e.body,n=[...t.scopes];return(...s)=>{const o=new Map;i.forEach(((t,e)=>{if("Identifier"!==t.type)throw new Error("Only simple parameters are supported");o.set(t.name,s[e])}));const a={steps:t.steps,scopes:[...n,o]},h=Ys(a,r);return t.steps=a.steps,h instanceof Ks?h.value:!0===e.expression?h:void 0}}case"BinaryExpression":{const i=Ys(t,e.left),r=Ys(t,e.right);switch(e.operator){case"===":return i===r;case"!==":return i!==r;case"==":return i==r;case"!=":return i!=r;case"<":return i<r;case"<=":return i<=r;case">":return i>r;case">=":return i>=r;case"+":return i+r;case"-":return i-r;case"*":return i*r;case"/":return i/r;case"%":return i%r;case"**":return i**r;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"LogicalExpression":{const i=Ys(t,e.left);switch(e.operator){case"&&":return i&&Ys(t,e.right);case"||":return i||Ys(t,e.right);case"??":return i??Ys(t,e.right);default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"UnaryExpression":{const i=Ys(t,e.argument);switch(e.operator){case"!":return!i;case"-":return-i;case"+":return+i;case"typeof":return typeof i;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"ConditionalExpression":return Ys(t,e.test)?Ys(t,e.consequent):Ys(t,e.alternate);case"AssignmentExpression":{const i=e.left;if("Identifier"!==i.type||"="!==e.operator)throw new Error("Only simple assignments are supported");const r=Ys(t,e.right);return((t,e,i)=>{for(let r=t.scopes.length-1;r>=0;r--)if(t.scopes[r].has(e))return void t.scopes[r].set(e,i);throw new Error(`Cannot assign to unknown identifier "${e}"`)})(t,i.name,r),r}case"ArrayExpression":{const i=[];for(const r of e.elements)if(r)if("SpreadElement"===r.type){const e=Ys(t,r.argument);Array.isArray(e)&&i.push(...e)}else i.push(Ys(t,r));return i}case"ObjectExpression":{const i={};for(const r of e.properties){if("SpreadElement"===r.type){const e=Ys(t,r.argument);if(e&&"object"==typeof e)for(const[t,r]of Object.entries(e))i[String(Ws(t))]=r;continue}const e=r.key,n=Ws(r.computed?Ys(t,e):"Identifier"===e.type?e.name:e.value);i[String(n)]=Ys(t,r.value)}return i}default:throw new Error(`Unsupported syntax: ${e.type}`)}},Qs={undefined:void 0,NaN:NaN,Infinity:1/0,Math,JSON,Number,String,Boolean,Array,Object,Date,parseInt,parseFloat,isNaN,isFinite};class Xs{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchSpec(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load spec "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}class to{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchOptions(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load options "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}var eo=Symbol.for("formkrafter.core.services"),io=globalThis,ro=io[eo]??={jsRunnerService:new class{validateJs(t,e={ecmaVersion:"latest",allowReturnOutsideFunction:!0}){try{return Yt(t,e),{valid:!0}}catch(t){return{valid:!1,error:t instanceof Error?t:new Error(String(t))}}}eval(t,e={}){return function(t,e={}){const i=Yt(t,{ecmaVersion:"latest",allowReturnOutsideFunction:!0}),r={steps:0,scopes:[new Map(Object.entries({...Qs,...e})),new Map]},n=Ys(r,i);return n instanceof Ks?n.value:void 0}(t,e)}},dataSourceService:new class{defaults;cache=new Map;constructor(t={}){this.defaults=t}fetchOptions(t,e){const i={...this.defaults.headers,...e?.headers},r={};Object.keys(i).length&&(r.headers=i),this.defaults.credentials&&(r.credentials=this.defaults.credentials);const n=`${t}|${JSON.stringify(r)}`;let s=this.cache.get(n);return s||(s=fetch(t,Object.keys(r).length?r:void 0).then((e=>{if(!e.ok)throw new Error(`Data source request failed (${e.status}): ${t}`);return e.json()})).then((e=>{if(!Array.isArray(e))throw new Error(`Data source did not return an array: ${t}`);return e})).catch((t=>{throw this.cache.delete(n),t})),this.cache.set(n,s)),s}},fileUploadService:new class{async upload(t){const e=globalThis.btoa;if(!e)throw new Error("No base64 encoder available");const i=new Uint8Array(await t.arrayBuffer());let r="";for(const t of i)r+=String.fromCharCode(t);return{name:t.name,type:t.type,size:t.size,url:`data:${t.type};base64,${e(r)}`}}},specSourceService:new Xs,optionSourceService:new to};ro.specSourceService??=new Xs,ro.optionSourceService??=new to;var no=(t,e)=>{try{return ro.jsRunnerService.eval(t,{dataMap:e??{}})}catch(t){return t instanceof Error?t:new Error(String(t))}},so=(t,e)=>((t,e)=>((t,e)=>t?.filter((t=>((t,e)=>"jsonLogic"===t.type?null!=t.logic&&!0===n.apply(t.logic,e):"javaScript"===t.type&&!!t.code&&!0===no(t.code,e))(t,e))))(t,e)?.map((t=>t.effects)).flat().filter((t=>null!=t)))(t,e)?.map((t=>{let i;return t.property?("boolean"===t.property.type?i=t.boolean:"logic"===t.property.type&&null!=t.logic?i=n.apply(t.logic,e):"code"===t.property.type&&t.code?i=no(t.code,e):"string"===t.property.type&&(i=t.string),{[t.property.target]:i}):{}})).flat().reduce(((t,e)=>({...t,...e})),{})??{hidden:!1},oo=(t,e)=>{if(Array.isArray(e))return e.map((e=>oo(t,e))).filter(Boolean).join(", ");if(!0===e)return Gs("recap.yes","Yes");if(!1===e)return Gs("recap.no","No");if(e&&"object"==typeof e)return"string"==typeof e.name&&"url"in e?e.name:Object.values(e).filter((t=>"string"==typeof t&&t)).join(" ");const i=String(e??"");if(null!=t.configs?.options){const e=Ds(t.configs.options,"string"==typeof t.configs.labelKey?t.configs.labelKey:"label","string"==typeof t.configs.valueKey?t.configs.valueKey:"value").find((t=>t.value===i));if(e)return e.label}return i},ao=t=>null==t||""===t||Array.isArray(t)&&0===t.length,ho=(t,e)=>String(js(t.configs?.label,e)??t.name??t.configs?.key??""),uo=t=>{const e=[];for(const i of t.children??[]){const t=i.configs?.key;"input"===i.type&&t&&!t.startsWith("_")&&e.push(i)}return e},co=(t,e,i,r,n=!1)=>{if(!t)return[];const s=[];for(const o of t.children??[]){if("recap"===o.id||"action"===o.type)continue;if(!0===so(o.rules,e).hidden)continue;const t=o.configs?.key,a=ho(o,i);if("collection"===o.type){const n=t&&Array.isArray(e?.[t])?e[t]:[];if(!n.length&&!r)continue;const h=uo(o);s.push({kind:"collection",label:a,columns:h.map((t=>ho(t,i))),rows:n.map((t=>h.map((e=>{const i=t?.[e.configs.key];return ao(i)?"—":oo(e,i)}))))});continue}if("panel"===o.type){const t=js(o.configs?.label,i);if(n&&"string"==typeof t&&t.trim()){const n=co(o,e,i,r);n.length&&(s.push({kind:"section",label:t}),s.push(...n));continue}s.push(...co(o,e,i,r,n));continue}if("input"!==o.type||!t||t.startsWith("_"))continue;const h=e?.[t];ao(h)&&!r||s.push({kind:"field",label:a,value:ao(h)?"—":oo(o,h)})}return s},fo=(t,e)=>{const i=e(t),r=t.children?.map((t=>fo(t,e)));if(i===t.configs&&r===t.children)return t;const n={...t};return void 0===i?delete n.configs:n.configs=i,r&&(n.children=r),n};function lo(t){return fo(t,(t=>t.configs?.uid?t.configs:{...t.configs,uid:crypto.randomUUID()}))}function po(t){return fo(t,(t=>{if(!t.configs||!("uid"in t.configs))return t.configs;const{uid:e,...i}=t.configs;return Object.keys(i).length>0?i:void 0}))}var mo=(t,e)=>Array.isArray(t)?t.map((t=>mo(t,e))):(t=>null!=t&&"object"==typeof t&&!Array.isArray(t)&&"string"==typeof t.type&&"string"==typeof t.id)(t)?po(t):e.endsWith("/configs")&&null!=t&&"object"==typeof t?(t=>{const{uid:e,...i}=t;return i})(t):t;function vo(t){return t.map((t=>"value"in t?{...t,value:mo(t.value,t.path)}:t))}function yo(t,e){return t.replace(/\{(\w+)\}/g,((t,i)=>{const r=e?.[i];return null==r?"":String(r)}))}function go(t,e){if("string"!=typeof t||!t.trim())return;const i={};for(const r of t.split("\n")){const t=r.indexOf(":");if(t<=0)continue;const n=r.slice(0,t).trim(),s=yo(r.slice(t+1).trim(),e);n&&(i[n]=s)}return Object.keys(i).length?i:void 0}function $o(t,e,i){if(!i)return t;const r=t.includes("?")?"&":"?";return`${t}${r}${encodeURIComponent(e)}=${encodeURIComponent(i)}`}class wo{type;dataType;id;name;configsForm;category;styles;unWrapData;isPrivate;validators;defaultConfigs;constructor(t){this.type=t.type,this.dataType=t.dataType,this.id=t.id,this.name=t.name,this.configsForm=t.configsForm,this.category=t.category,this.styles=t.styles,this.unWrapData=t.unWrapData??!1,this.isPrivate=t.isPrivate??!1,this.validators=t.validators??[],this.defaultConfigs=t.defaultConfigs}getBrickEmptySpec(){return{type:this.type,dataType:this.dataType,id:this.id,name:this.name,...void 0!==this.category?{category:this.category}:{},...void 0!==this.configsForm?{configsForm:this.configsForm}:{},...void 0!==this.styles?{styles:this.styles}:{},...void 0!==this.defaultConfigs?{configs:{...this.defaultConfigs}}:{},validators:this.validators}}}var bo=new Un.Ajv({allErrors:!0});Jn(bo,["email","uri"]),Vn(bo);var _o=new WeakMap,Eo=new WeakMap,ko=t=>{if("required"===t.keyword)return t.params.missingProperty;if("errorMessage"===t.keyword){const e=t.params.errors?.[0];return e?ko(e):void 0}return t.instancePath.split("/").filter(Boolean)[0]},So=(t,e,i)=>{const r={},n=((t,e)=>{let i=_o.get(t);i||(i=new Map,_o.set(t,i));const r=e??"";let n=i.get(r);if(!n){const s=function(t,e){if(!t)return;const i={},r=[],n={},s=t=>{const i=js(t,e);return"string"==typeof i?i:void 0};for(const o of Ns(t)){const t=o.configs?.key,a=!0===o.configs?.multiple&&"object"===o.dataType?"array":o.dataType;if(!t||!a||"void"===a)continue;const h=o.validations?.find((t=>"required"===t.validator)),u={type:a,nullable:!h},c={type:Cs("type",e)};for(const t of o.validations??[]){const{validator:i,value:r}=t,n=s(t.message)??Cs(i,e,r);"minLength"===i&&null!=r?(u.minLength=Number(r),c.minLength=n):"maxLength"===i&&null!=r?(u.maxLength=Number(r),c.maxLength=n):"min"===i&&null!=r?(u.minimum=Number(r),c.minimum=n):"max"===i&&null!=r?(u.maximum=Number(r),c.maximum=n):"pattern"===i&&"string"==typeof r&&r?(u.pattern=r,c.pattern=n):"minItems"===i&&null!=r?(u.minItems=Number(r),c.minItems=n):"maxItems"===i&&null!=r?(u.maxItems=Number(r),c.maxItems=n):"email"===i?(u.format="email",c.format=n):"url"===i&&(u.format="uri",c.format=n)}u.errorMessage=c,i[t]=u,h&&(r.push(t),n[t]=s(h.message)??Cs("required",e))}return{type:"object",properties:i,required:r,...Object.keys(n).length?{errorMessage:{required:n}}:{},additionalProperties:!1}}(t,e);if(!s)return;try{n=bo.compile(s)}catch(e){return void((t,e)=>{const i=e instanceof Error?e.message:String(e);Eo.set(t,`the validation schema failed to compile, so no rule was enforced: ${i}`)})(t,e)}i.set(r,n)}return n})(t,i);if(n&&!n(e))for(const t of n.errors??[]){const e=ko(t);e&&!(e in r)&&t.message&&(r[e]=t.message)}for(const[n,s]of Object.entries(((t,e,i)=>{const r={},n=e??{};for(const e of Ns(t)){const t=e.configs?.key;if(t)for(const s of e.validations??[]){if("custom"!==s.validator||!s.customValidator)continue;const e=no(`const value = dataMap?.[${JSON.stringify(t)}];\n${s.customValidator}`,n);if(!0!==e&&null!=e&&!(t in r))if("string"==typeof e)r[t]=e;else if(e instanceof Error)r[t]=e.message;else{const e=js(s.message,i);r[t]="string"==typeof e?e:Cs("custom",i)}}}return r})(t,e,i)))n in r||(r[n]=s);const s="object"==typeof e&&null!==e?e:void 0;for(const e of((t,e)=>{const i=new Set,r=(t,n)=>{const s=n||!!t.rules?.length&&!0===so(t.rules,e).hidden,o=t.configs?.key;if(s&&o&&i.add(o),"collection"!==t.type)for(const e of t.children??[])r(e,s)};return r(t,!1),i})(t,s))delete r[e];return{valid:0===Object.keys(r).length,errors:r}};function xo(t){return t.split(".").slice(1).map((t=>`/children/${t}`)).join("")}function Oo(t,e){if(t.configs?.uid===e)return"";for(const[i,r]of(t.children??[]).entries()){const t=Oo(r,e);if(void 0!==t)return`/children/${i}${t}`}}function jo(t,e){let i=t;for(const t of e.split(".").slice(1))i=i?.children?.[Number(t)];return i}var Po=(Ss??xs).applyPatch,Io=(t,e,i)=>({spec:Po(t,e,!0,!1).newDocument,patches:e,inverse:i}),Co=(t,e)=>{const i=jo(t,e);if(!i)throw new Error(`No brick at path "${e}"`);return i},Ao=(t,e)=>{const i=Oo(t,e);if(void 0===i)throw new Error(`No brick with uid "${e}"`);let r=t;for(const t of i.split("/children/").slice(1))r=r.children[Number(t)];return{pointer:i,brick:r}},No=t=>JSON.parse(JSON.stringify(t));function To(t,e,i,r){const n=Co(t,i),s=xo(i),o=No(e);if(!n.children){const e=`${s}/children`;return Io(t,[{op:"add",path:e,value:[o]}],[{op:"remove",path:e}])}const a=`${s}/children/${Math.min(r??n.children.length,n.children.length)}`;return Io(t,[{op:"add",path:a,value:o}],[{op:"remove",path:a}])}function Mo(t,e){if("0"===e)throw new Error("Cannot remove the root brick");const i=Co(t,e),r=xo(e);return Io(t,[{op:"remove",path:r}],[{op:"add",path:r,value:i}])}function Ro(t,e,i){if("0"===e||"0"===i)throw new Error("Cannot move the root brick");const r=Co(t,e),n=e.split(".").map(Number),s=i.split(".").map(Number),o=n.length-1,a=n[o],h=s.length>o&&n.slice(0,o).every(((t,e)=>t===s[e])),u=[...s];if(h){if(u[o]===a&&u.length>n.length)throw new Error(`Cannot move a brick into its own subtree ("${e}" → "${i}")`);u[o]>a&&(u[o]-=1)}const c=xo(e),f=xo(u.join("."));return Io(t,[{op:"remove",path:c},{op:"add",path:f,value:r}],[{op:"remove",path:f},{op:"add",path:c,value:r}])}var Do=t=>({...t,...t.configs?{configs:{...t.configs,uid:crypto.randomUUID()}}:{},...t.children?{children:t.children.map(Do)}:{}});function Lo(t,e){if("0"===e)throw new Error("Cannot duplicate the root brick");const i=Co(t,e),r=e.split("."),n=Number(r[r.length-1])+1,s=xo([...r.slice(0,-1),String(n)].join(".")),o=Do(No(i));return Io(t,[{op:"add",path:s,value:o}],[{op:"remove",path:s}])}var zo=(t,e,i,r,n)=>{const s=`${e}/${i}`;return void 0===n?Io(t,[{op:"add",path:s,value:r}],[{op:"remove",path:s}]):Io(t,[{op:"replace",path:s,value:r}],[{op:"replace",path:s,value:n}])};function Uo(t,e,i){const{pointer:r,brick:n}=Ao(t,e),s={...n.configs,...i};return zo(t,r,"configs",s,n.configs)}function qo(t,e,i){const{pointer:r,brick:n}=Ao(t,e),s={...n.styles,...i};return zo(t,r,"styles",s,n.styles)}function Fo(t,e,i){const{pointer:r,brick:n}=Ao(t,e);return zo(t,r,"validations",i,n.validations)}function Vo(t,e,i){const{pointer:r,brick:n}=Ao(t,e);return zo(t,r,"rules",i,n.rules)}class Bo{past=[];future=[];record(t){this.past.push({patches:t.patches,inverse:t.inverse}),this.future=[]}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}undo(t){const e=this.past.pop();if(e)return this.future.push(e),Po(t,e.inverse,!0,!1).newDocument}redo(t){const e=this.future.pop();if(e)return this.past.push(e),Po(t,e.patches,!0,!1).newDocument}clear(){this.past=[],this.future=[]}}var Go=t=>"nested-form"===t.id&&"string"==typeof t.configs?.specRef,Ho=t=>{if(!t)return!1;for(const{brick:e}of As(t))if(Go(e)&&e.configs?.specRef)return!0;return!1};async function Ko(t,e={}){const i=e.specSourceService??ro.specSourceService,r=e.maxDepth??5,n=async(t,e)=>{if(Go(t)&&t.configs?.specRef){const s=String(t.configs.specRef);if(e.includes(s))throw new Error(`Circular nested form reference: ${[...e,s].join(" → ")}`);if(e.length>=r)throw new Error(`Nested forms exceed the maximum depth of ${r} (${s})`);const o=await i.fetchSpec(s),a=await n(structuredClone(o),[...e,s]);return{type:"panel",id:"group",name:t.name,configs:{...t.configs,label:t.configs.label??a.name},styles:t.styles,rules:t.rules,children:a.children??[]}}return t.children?.length?{...t,children:await Promise.all(t.children.map((t=>n(t,e))))}:t};return n(structuredClone(t),[])}export{go as A,Ds as B,no as C,Ns as D,wo as E,co as F,js as G,Vs as H,zs as I,Bo as S,Gs as a,Ts as b,To as c,jo as d,lo as e,Bs as f,so as g,Mo as h,Lo as i,qo as j,Fo as k,Vo as l,Ro as m,As as n,vo as o,po as p,Ho as q,Ps as r,ro as s,Ko as t,Uo as u,So as v,Ms as w,Os as x,yo as y,$o as z}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamline-pulse/formkrafter-wc",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "FormKrafter web components (Stencil)",
6
6
  "main": "dist/components/index.js",