@trustme24/flext 1.10.4 → 1.10.5
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 +1 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/src/lib/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -562,6 +562,6 @@ ${u.join(`
|
|
|
562
562
|
:host *::after {
|
|
563
563
|
--un-content: '';
|
|
564
564
|
}
|
|
565
|
-
`;var qi=yn(pa(),1),Xf=Pc({presets:[rd(),rs()],preflights:[{getCSS:()=>od}],theme:{}}),Tr=10,Vi="string",Qf=Jf.default,Mr=class extends qi.default.Visitor{data=[];match=()=>!0;constructor(e){super(),e&&this.setMatchHandler(e)}onCollect(e){this.match(e)&&this.data.push(e)}setMatchHandler(e){return this.match=e,this}setAst(e){return this.accept(e),this}collect(e){return this.data=[],this.setAst(e),this.data}},ma=class extends Mr{CommentStatement(e){return this.onCollect(e.value),super.CommentStatement(e)}},ga=class extends Mr{ContentStatement(e){return this.onCollect(e.value),super.ContentStatement(e)}},ba=class extends Mr{PathExpression(e){let r=e.original,n=i=>r===i;return n("if")||n("unless")||n("each")||n("with")?super.PathExpression(e):(this.onCollect(e.original),super.PathExpression(e))}},ya=class extends ma{match=mn.macro},va=class extends ga{match=mn.htmlH1Somewhere};function pe(t,...e){return e.includes(t)}function ji(t,e){return t.hasOwnProperty(e)}function et(t){return!pe(t,null,void 0)}function $e(t){return et(t)&&!isNaN(Number(t))}function Wi(t){return typeof t=="object"&&t!==null}function I(t){return Wi(t)?JSON.stringify(t):typeof t=="string"?`'${t}'`:String(t)}function Sa(t){return qi.default.parse(t)}function Bi(t){return qi.default.compile(t)}function Ui(t,e={},r={}){return t(e,{helpers:r})}async function $a(t,e={},r={}){let n=r?.helpers??{},i=!!(r?.doGenerateGlobalStyles??!0),o=await Xf,s=Ui(t,e,n),{css:a}=await o.generate(s,{preflights:i});return a}function eh(t){return[...new Set(t)]}function th(t){let e=new ba().collect(t);return eh(e)}function Fi(t,e=Tr){if(e<=0)throw new ft("Flext: Unable to get the model: The model is too deep");let[r,...n]=t?.split(".")??[],i={name:r};return n?.length>0&&(i.$=[Fi(n?.join(".")||"",e-1)]),i}function rh(t,e=Tr){let n={name:"root",$:[Fi(t,e)]};return n.addPath=(i,o=Tr)=>{let s=Fi(i,o),a=n,l=s;for(let c=0;c<99;c++){if(!l)return;let d=a?.$??[],u=null;for(let p of d)l?.name===p?.name&&(u=p);if(!u){a.$=[...d,l];return}let[h]=l.$??[];a=u,l=h??null}},n}function Ea(t){let[e,...r]=th(t),n=rh(e);for(let i of r){let o=s=>i.startsWith(s);o(".")||o("/")||o("@")||o("this")||n.addPath(i)}return n}function Hi(t,e,r={},n=Tr){if(n<=0)throw new ft("Flext: Unable to get data model: The data model is too deep");let i=O=>e?.find(T=>T?.name===O)??null,o=r?.fieldName??t?.name??null,s=i(o),a=s?.order??null,l=t?.$??[],c=l?.length?"object":s?.type??Vi,d=t?.name??null,u=s?.label??null,h=s?.hint??null,p=s?.min??null,m=s?.max??null,b=s?.minLength??null,k=s?.maxLength??null,v=s?.options??null,x=s?.isRequired??null,S=[];for(let O of l){let T=O?.name??null;S.push(Hi(O,e,{fieldName:o+"."+T},n-1))}let y=S.sort((O,T)=>{let A=O?.extra?.fieldName??null,U=i(A)??{},V=U?.order??null,Be=U?.extra?.absoluteOrder??null,ut=T?.extra?.fieldName??null,Ue=i(ut)??{},le=Ue?.order??null,bn=Ue?.extra?.absoluteOrder??null;return Ri(V,le)!==0?Ri(V,le):Ri(Be,bn)}),$=S?.length&&S.every(O=>O?.isRequired),M=et(x)?x:$;return{type:c,name:d,label:u,hint:h,min:p,max:m,minLength:b,maxLength:k,order:a,options:v,isRequired:M,extra:{fieldName:o},$:y}}function nh(t){let e=s=>t?.match(s)??null,r=s=>{let a=s?.groups?.value??null;return{name:s?.groups?.name??a,value:a}},n=e(De.macroParam),i=e(De.macroNamedParam),o=e(De.macroSimpleParam);return n?r(n):i?r(i):o?r(o):null}function ih(t,e=!0){let r=t?.match(De.macroParams)??[],n=[];for(let i of r){let o=nh(i);if(o)n.push(o);else if(e)throw new Ge("Flext: Unable to parse the macros: Bad token: "+I(i))}return n}function _a(t,e=!0){let r=new ya().collect(t),n=[];for(let i of r){let o=i?.trim()?.match(De.macro)??null;if(!o){if(e)throw new Ge("Flext: Unable to parse the macros: Bad macro: "+I(i));return null}let s=o?.groups?.name??null,a=o?.groups?.params??null,l=ih(a,e);n.push({name:s,params:l})}return n}function Ca(t,e=!0){let r=new va().collect(t),n=[];for(let i of r){let o=i?.trim()?.match(De.htmlH1Somewhere)??null;if(!o){if(e)throw new Ge("Flext: Unable to parse H1: Bad HTML: "+I(i));return null}for(let s of o)n.push(String(s))}return n}function Gi(t,e,r=Tr){if(r<=0)throw new ft("Flext: Unable to verify the data: The data model is too deep");let n=[],i=a=>!pe(a,"",null,void 0),o=a=>String(a).length,s=(a,l)=>{n.push(new Gt(a,l))};for(let a of e){let l=a?.extra?.fieldName??null,c=l??a?.name??"Unknown",d=t[a.name]??null;if(!i(d)&&a?.isRequired){s(`Field '${c}' is required (${I(d)} is passed)`,l);continue}if(pe(a?.type,"number","date")&&i(a?.min)&&i(d)&&a?.min>d){s(`'${c}' field value is less than the range (${I(d)} is passed, the minimum is ${I(a?.min)})`,l);continue}if(pe(a?.type,"number","date")&&i(a?.max)&&i(d)&&a?.max<d){s(`'${c}' field value is greater than the range (${I(d)} is passed, the maximum is ${I(a?.max)})`,l);continue}if(!pe(a?.type,"object","array","mixed")&&i(a?.minLength)&&i(d)&&a?.minLength>o(d)){s(`'${c}' field value is shorter than the range (${I(d)} is passed, the minimum is ${I(a?.minLength)})`,l);continue}if(!pe(a?.type,"object","array","mixed")&&i(a?.maxLength)&&i(d)&&a?.maxLength<o(d)){s(`'${c}' field value is longer than the range (${I(d)} is passed, the maximum is ${I(a?.maxLength)})`,l);continue}if(pe(a?.type,"string")&&$e(a?.min)&&i(d)&&Number(a?.min)>o(d)){s(`'${c}' field value is shorter than the range (${I(d)} is passed, the minimum is ${I(a?.min)})`,l);continue}if(pe(a?.type,"string")&&$e(a?.max)&&i(d)&&Number(a?.max)<o(d)){s(`'${c}' field value is longer than the range (${I(d)} is passed, the maximum is ${I(a?.max)})`,l);continue}n.push(...Gi(d??{},a.$,r-1))}return n}function Zi(t){return String(t??"")}function pn(t){return pe(t,null,void 0)?null:Zi(t)}function gn(t,e=!0){let r=Wi(t)&&t instanceof Date,n=typeof t=="string"&&De.dbDateStr.test(t),i=(a,l=!0)=>{let c=new Date(a);if(isNaN(c.getTime())&&l)throw new Ge("Flext: Unable to get date: The date is invalid: "+I(a));return isNaN(c.getTime())?null:c},o=(a,l=!0)=>{let[c,d,u]=a?.split("-")?.map(Number)??[];if(c&&d&&u)return F.
|
|
565
|
+
`;var qi=yn(pa(),1),Xf=Pc({presets:[rd(),rs()],preflights:[{getCSS:()=>od}],theme:{}}),Tr=10,Vi="string",Qf=Jf.default,Mr=class extends qi.default.Visitor{data=[];match=()=>!0;constructor(e){super(),e&&this.setMatchHandler(e)}onCollect(e){this.match(e)&&this.data.push(e)}setMatchHandler(e){return this.match=e,this}setAst(e){return this.accept(e),this}collect(e){return this.data=[],this.setAst(e),this.data}},ma=class extends Mr{CommentStatement(e){return this.onCollect(e.value),super.CommentStatement(e)}},ga=class extends Mr{ContentStatement(e){return this.onCollect(e.value),super.ContentStatement(e)}},ba=class extends Mr{PathExpression(e){let r=e.original,n=i=>r===i;return n("if")||n("unless")||n("each")||n("with")?super.PathExpression(e):(this.onCollect(e.original),super.PathExpression(e))}},ya=class extends ma{match=mn.macro},va=class extends ga{match=mn.htmlH1Somewhere};function pe(t,...e){return e.includes(t)}function ji(t,e){return t.hasOwnProperty(e)}function et(t){return!pe(t,null,void 0)}function $e(t){return et(t)&&!isNaN(Number(t))}function Wi(t){return typeof t=="object"&&t!==null}function I(t){return Wi(t)?JSON.stringify(t):typeof t=="string"?`'${t}'`:String(t)}function Sa(t){return qi.default.parse(t)}function Bi(t){return qi.default.compile(t)}function Ui(t,e={},r={}){return t(e,{helpers:r})}async function $a(t,e={},r={}){let n=r?.helpers??{},i=!!(r?.doGenerateGlobalStyles??!0),o=await Xf,s=Ui(t,e,n),{css:a}=await o.generate(s,{preflights:i});return a}function eh(t){return[...new Set(t)]}function th(t){let e=new ba().collect(t);return eh(e)}function Fi(t,e=Tr){if(e<=0)throw new ft("Flext: Unable to get the model: The model is too deep");let[r,...n]=t?.split(".")??[],i={name:r};return n?.length>0&&(i.$=[Fi(n?.join(".")||"",e-1)]),i}function rh(t,e=Tr){let n={name:"root",$:[Fi(t,e)]};return n.addPath=(i,o=Tr)=>{let s=Fi(i,o),a=n,l=s;for(let c=0;c<99;c++){if(!l)return;let d=a?.$??[],u=null;for(let p of d)l?.name===p?.name&&(u=p);if(!u){a.$=[...d,l];return}let[h]=l.$??[];a=u,l=h??null}},n}function Ea(t){let[e,...r]=th(t),n=rh(e);for(let i of r){let o=s=>i.startsWith(s);o(".")||o("/")||o("@")||o("this")||n.addPath(i)}return n}function Hi(t,e,r={},n=Tr){if(n<=0)throw new ft("Flext: Unable to get data model: The data model is too deep");let i=O=>e?.find(T=>T?.name===O)??null,o=r?.fieldName??t?.name??null,s=i(o),a=s?.order??null,l=t?.$??[],c=l?.length?"object":s?.type??Vi,d=t?.name??null,u=s?.label??null,h=s?.hint??null,p=s?.min??null,m=s?.max??null,b=s?.minLength??null,k=s?.maxLength??null,v=s?.options??null,x=s?.isRequired??null,S=[];for(let O of l){let T=O?.name??null;S.push(Hi(O,e,{fieldName:o+"."+T},n-1))}let y=S.sort((O,T)=>{let A=O?.extra?.fieldName??null,U=i(A)??{},V=U?.order??null,Be=U?.extra?.absoluteOrder??null,ut=T?.extra?.fieldName??null,Ue=i(ut)??{},le=Ue?.order??null,bn=Ue?.extra?.absoluteOrder??null;return Ri(V,le)!==0?Ri(V,le):Ri(Be,bn)}),$=S?.length&&S.every(O=>O?.isRequired),M=et(x)?x:$;return{type:c,name:d,label:u,hint:h,min:p,max:m,minLength:b,maxLength:k,order:a,options:v,isRequired:M,extra:{fieldName:o},$:y}}function nh(t){let e=s=>t?.match(s)??null,r=s=>{let a=s?.groups?.value??null;return{name:s?.groups?.name??a,value:a}},n=e(De.macroParam),i=e(De.macroNamedParam),o=e(De.macroSimpleParam);return n?r(n):i?r(i):o?r(o):null}function ih(t,e=!0){let r=t?.match(De.macroParams)??[],n=[];for(let i of r){let o=nh(i);if(o)n.push(o);else if(e)throw new Ge("Flext: Unable to parse the macros: Bad token: "+I(i))}return n}function _a(t,e=!0){let r=new ya().collect(t),n=[];for(let i of r){let o=i?.trim()?.match(De.macro)??null;if(!o){if(e)throw new Ge("Flext: Unable to parse the macros: Bad macro: "+I(i));return null}let s=o?.groups?.name??null,a=o?.groups?.params??null,l=ih(a,e);n.push({name:s,params:l})}return n}function Ca(t,e=!0){let r=new va().collect(t),n=[];for(let i of r){let o=i?.trim()?.match(De.htmlH1Somewhere)??null;if(!o){if(e)throw new Ge("Flext: Unable to parse H1: Bad HTML: "+I(i));return null}for(let s of o)n.push(String(s))}return n}function Gi(t,e,r=Tr){if(r<=0)throw new ft("Flext: Unable to verify the data: The data model is too deep");let n=[],i=a=>!pe(a,"",null,void 0),o=a=>String(a).length,s=(a,l)=>{n.push(new Gt(a,l))};for(let a of e){let l=a?.extra?.fieldName??null,c=l??a?.name??"Unknown",d=t[a.name]??null;if(!i(d)&&a?.isRequired){s(`Field '${c}' is required (${I(d)} is passed)`,l);continue}if(pe(a?.type,"number","date")&&i(a?.min)&&i(d)&&a?.min>d){s(`'${c}' field value is less than the range (${I(d)} is passed, the minimum is ${I(a?.min)})`,l);continue}if(pe(a?.type,"number","date")&&i(a?.max)&&i(d)&&a?.max<d){s(`'${c}' field value is greater than the range (${I(d)} is passed, the maximum is ${I(a?.max)})`,l);continue}if(!pe(a?.type,"object","array","mixed")&&i(a?.minLength)&&i(d)&&a?.minLength>o(d)){s(`'${c}' field value is shorter than the range (${I(d)} is passed, the minimum is ${I(a?.minLength)})`,l);continue}if(!pe(a?.type,"object","array","mixed")&&i(a?.maxLength)&&i(d)&&a?.maxLength<o(d)){s(`'${c}' field value is longer than the range (${I(d)} is passed, the maximum is ${I(a?.maxLength)})`,l);continue}if(pe(a?.type,"string")&&$e(a?.min)&&i(d)&&Number(a?.min)>o(d)){s(`'${c}' field value is shorter than the range (${I(d)} is passed, the minimum is ${I(a?.min)})`,l);continue}if(pe(a?.type,"string")&&$e(a?.max)&&i(d)&&Number(a?.max)<o(d)){s(`'${c}' field value is longer than the range (${I(d)} is passed, the maximum is ${I(a?.max)})`,l);continue}n.push(...Gi(d??{},a.$,r-1))}return n}function Zi(t){return String(t??"")}function pn(t){return pe(t,null,void 0)?null:Zi(t)}function gn(t,e=!0){let r=Wi(t)&&t instanceof Date,n=typeof t=="string"&&De.dbDateStr.test(t),i=(a,l=!0)=>{let c=new Date(a);if(isNaN(c.getTime())&&l)throw new Ge("Flext: Unable to get date: The date is invalid: "+I(a));return isNaN(c.getTime())?null:c},o=(a,l=!0)=>{let[c,d,u]=a?.split("-")?.map(Number)??[];if(c&&d&&u)return F.fromObject({year:c,month:d,day:u}).toJSDate();if(l)throw new se("Flext: Unable to get date: The date is invalid: "+I(a));return null},s=(a,l=!0)=>{let c=F.fromISO(a);if(c.isValid)return c.toJSDate();if(l)throw new Ge("Flext: Unable to get date: The date is invalid: "+I(a));return null};return r?t:$e(t)?i(t,e):n?o(t,e):s(t,e)}function Oa(t){let e=Qf(String(t)).trim(),r=(n,i="")=>e=e.replace(n,i);return r(`
|
|
566
566
|
`," "),r(/\s{2,}/mg," "),r(/[^\p{L}\d\s]/mgu),e.trim()}function oh(t){let e=t,r=(n,i="")=>e=e.replace(n,i);return r("["),r("]"),e.trim()}function ka(t){return $e(t)||Wi(t)&&t instanceof Date?t:null}function xa(t){return $e(t)?t:null}function sh(t){return et(t)?Number(t):null}function Ta(t){if(typeof t!="string")try{return JSON.parse(t)}catch{return t??null}else return t??null}function Ma(...t){return t.reduce((e,r)=>Number(e)+Number(r),0)}function wa(t,e){return!!String(e).trim().match(t)}function Ri(t,e){return!et(t)&&!et(e)?0:et(t)?et(e)?t-e:-1:1}function Na(t){return(t?.params??[]).map(r=>r?.value??null)}function Pa(t){let e=t?.name??null,r=t?.params??[],[n,...i]=r,o=y=>{let $=i?.find(M=>M?.name===y)??null;return $&&$?.value?$?.value??null:$&&$?.name?!0:null},s=Zi(o("type")??Vi),a=pn(n?.value),l=pn(o("label")),c=pn(o("descr")),d=pn(o("hint")),u=ka(o("min")),h=ka(o("max")),p=xa(o("minLength")),m=xa(o("maxLength")),b=sh(o("order")),k=Ta(o("value")),v=!!o("required");if(!a)throw new se("Unable to get field: The 'name' param is not set: "+I(a));let x=oh(a);return{type:s,name:x,label:l,descr:c,hint:d,min:u,max:h,minLength:p,maxLength:m,order:b,value:k,isRequired:v,extra:{macroName:e}}}function Aa(t){let e=t?.params??[],[r,...n]=e,i=h=>{let p=n?.find(m=>m?.name===h)??null;return p&&p?.value?p?.value??null:p&&p?.name?!0:null},o=Zi(i("type")??Vi),s=r?.value??null,a=i("for")??null,l=i("label")??null,c=i("descr")??null,d=Ta(i("value")??s),u=!!i("disabled");if(!s)throw new se("Unable to get field option: The 'name' param is not set: "+I(s));if(!a)throw new se(`Unable to get field option '${s}': The 'for' param is not set: `+I(s));return{type:o,name:s,fieldName:a,label:l,descr:c,value:d,isDisabled:u}}function La(t,e){let r=n=>t?.filter(i=>i?.fieldName===n)??[];for(let n of e)r(n.name)?.length&&(n.options=r(n.name))}function Da(t){for(let[e,r]of t.entries())r?.extra?r.extra.absoluteOrder=e:r.extra={absoluteOrder:e}}function te(t={}){return{helpers:t?.helpers??null}}var De=class{static dbDateStr=/^\d+-\d+-\d+$/;static macro=/^@(?<name>.+?) (?<params>.+)$/;static macroParams=/(?<param>".+?")|(?<namedParam>[a-zA-Z0-9]+=".+?")|(?<simplaeParam>[a-zA-Z0-9]+)/gm;static macroParam=/^"(?<value>.+)"$/;static macroNamedParam=/^(?<name>.+)="(?<value>.+)"$/;static macroSimpleParam=/^(?<name>[a-zA-Z]+)$/;static htmlH1Somewhere=/\<h1.*?\>(?<value>.*)\<\/h1.*?\>/gs},mn=class{static macro(e){return wa(De.macro,e)}static htmlH1Somewhere(e){return wa(De.htmlH1Somewhere,e)}};var Xi={};no(Xi,{array:()=>ah,cond:()=>lh,date:()=>ch,match:()=>dh,math:()=>mh,media:()=>bh,number:()=>Bh,put:()=>Hh,string:()=>Gh});function Yi(t){let e=t?.args??[],[r,n,i]=e,o=(s,a)=>{let l=a?.split(".")??[],c=[];for(let d of s){let u=d;for(let h of l)u=u[h];c.push(u)}return c};switch(r){case"destruct":return o(n,i);case"check":return Array.isArray(n);default:return r}}function e3(t){let e=t?.args??[],[r,n]=e;return Yi({...t,args:["destruct",r,n]})}function t3(t){let e=t?.args??[],[r]=e;return Yi({...t,args:["check",r]})}var ah=te({helpers:{op:Yi,destruct:e3,check:t3,__default:Yi}});function ct(t){let e=t?.args??[],r=t?.namedArgs??{},[n,i,o,...s]=e,{soft:a}=r;if(n==="not")return!i;if(a)switch(i){case"equal":return n==o;case"notEqual":return n!=o;default:throw new ge("Condition: Unknown operation: "+I(i))}let l=(...d)=>d.reduce((u,h)=>u&&h),c=(...d)=>d.reduce((u,h)=>u||h);switch(i){case"equal":return n===o;case"notEqual":return n!==o;case"and":return l(n,o,...s);case"or":return c(n,o,...s);case"greater":return Number(n)>Number(o);case"less":return Number(n)<Number(o);default:throw new ge("Condition: Unknown operation: "+I(i))}}function r3(t){let e=t?.args??[],[r]=e;return ct({...t,args:["not",r]})}function n3(t){let e=t?.args??[],[r,n]=e;return ct({...t,args:[r,"equal",n]})}function i3(t){let e=t?.args??[],[r,n]=e;return ct({...t,args:[r,"notEqual",n]})}function o3(t){let e=t?.args??[],[r,...n]=e;return ct({...t,args:[r,"and",...n]})}function s3(t){let e=t?.args??[],[r,...n]=e;return ct({...t,args:[r,"or",...n]})}function a3(t){let e=t?.args??[],[r,n]=e;return ct({...t,args:[r,"greater",n]})}function l3(t){let e=t?.args??[],[r,n]=e;return ct({...t,args:[r,"less",n]})}var lh=te({helpers:{op:ct,not:r3,equal:n3,notEqual:i3,and:o3,or:s3,greater:a3,less:l3,__default:ct}});function me(t){let e=t?.flext??{},r=t?.args??[],n=t?.namedArgs??{},[i,o]=r,{padding:s,genitive:a,timeZone:l,lang:c}=n;if(!i)return null;let d=F.local();i!=="now"&&(d=F.fromJSDate(gn(i))),(l||e?.timeZone)&&(d=d.setZone(l??e?.timeZone)),(c||e?.lang)&&(d=d.setLocale(c??e?.lang));let u=(h,p=2)=>String(h||"").padStart(Number(p),"0");if(et(s))switch(o){case"seconds":return u(d.second,s);case"minutes":return u(d.minute,s);case"hours":return u(d.hour,s);case"day":return u(d.day,s);case"month":return u(d.month,s);case"year":return u(d.year,4);default:throw new ge(`Date: Operation ${I(o)} is not compatible with argument 'padding'`)}if(a){if(o==="monthText")return d.toLocaleString({day:"numeric",month:"long"}).replace(/[^\p{L}]/gu,"").toLowerCase();throw new ge(`Date: Operation ${I(o)} is not compatible with argument 'genitive'`)}switch(o){case"seconds":return d.second;case"minutes":return d.minute;case"hours":return d.hour;case"day":return d.day;case"month":return d.month;case"monthText":return d.toLocaleString({month:"long"}).toLowerCase();case"year":return d.year;case"format":return d.toLocaleString();case"text":return d.toLocaleString({day:"numeric",month:"long",year:"numeric"});case"unix":return d.toMillis();case"iso":return d.toISOTime();default:return d}}function c3(t){return me({...t,args:["now"]})}function u3(t){let e=t?.args??[],[r]=e,n=t?.namedArgs??{},i=n?.padding??2;return me({...t,args:[r,"seconds"],namedArgs:{...n,padding:i}})}function d3(t){let e=t?.args??[],[r]=e,n=t?.namedArgs??{},i=n?.padding??2;return me({...t,args:[r,"minutes"],namedArgs:{...n,padding:i}})}function f3(t){let e=t?.args??[],[r]=e,n=t?.namedArgs??{},i=n?.padding??2;return me({...t,args:[r,"hours"],namedArgs:{...n,padding:i}})}function h3(t){let e=t?.args??[],[r]=e,n=t?.namedArgs??{},i=n?.padding??2;return me({...t,args:[r,"day"],namedArgs:{...n,padding:i}})}function p3(t){let e=t?.args??[],[r]=e,n=t?.namedArgs??{},i=n?.padding??2;return me({...t,args:[r,"month"],namedArgs:{...n,padding:i}})}function m3(t){let e=t?.args??[],[r]=e,n=t?.namedArgs??{},i=!n?.nominative;return me({...t,args:[r,"monthText"],namedArgs:{...n,genitive:i}})}function g3(t){let e=t?.args??[],[r]=e,n=t?.namedArgs??{},i=n?.padding??2;return me({...t,args:[r,"year"],namedArgs:{...n,padding:i}})}function Ia(t){let e=t?.args??[],[r]=e;return me({...t,args:[r,"format"]})}function b3(t){let e=t?.args??[],[r]=e;return me({...t,args:[r,"text"]})}function y3(t){let e=t?.args??[],[r]=e;return me({...t,args:[r,"unix"]})}function v3(t){let e=t?.args??[],[r]=e;return me({...t,args:[r,"iso"]})}var ch=te({helpers:{op:me,now:c3,seconds:u3,minutes:d3,hours:f3,day:h3,month:p3,monthText:m3,year:g3,format:Ia,text:b3,unix:y3,iso:v3,__default:me}});function k3(t){let e=t?.args??[],[r]=e,n=t?.self??null,i=t?.getContent??null;return n.__flext_match_value=r,n.__flext_match_isCompleted=!1,i()}function uh(t){let e=t?.args??[],r=t?.self??null,n=r.__flext_match_value??null,i=t?.getContent??null;if(!r.__flext_match_isCompleted){for(let o of e)if(n===o)return r.__flext_match_isCompleted=!0,i()}return""}function x3(t){let r=(t?.self??null).__flext_match_value??null;return uh({...t,args:[r]})}var dh=te({helpers:{case:uh,fallback:x3,__default:k3}});function Ee(t){let e=t?.args??[],[r,n,i,...o]=e,s=(...l)=>{let[c,...d]=l,u=Math[c]??null;if(u)return u(...d);throw new ge("Math: Unknown operation: "+I(c))},a=(...l)=>{let c=[];for(let d of l)if($e(d))c.push(d);else if(Array.isArray(d)&&d.every($e))c.push(...d);else throw new se("Math: Unable to sum: The given arguments are not numbers: "+I(l));return c};switch(n){case"plus":case"sum":return Ma(...a(r,i||0,...o));case"minus":return Number(r)-Number(i||0);case"multiply":return Number(r)*Number(i||1);case"divide":return Number(r)/Number(i||1);case"intDivide":return Number(r)%Number(i||1);case"power":return Number(r)**Number(i||1);default:return s(...e)}}function w3(t){let e=t?.args??[],[r,n,...i]=e;return Ee({...t,args:[r,"plus",n,...i]})}function S3(t){let e=t?.args??[],[r,n,...i]=e;return Ee({...t,args:[r,"sum",n,...i]})}function $3(t){let e=t?.args??[],[r,n]=e;return Ee({...t,args:[r,"minus",n]})}function fh(t){let e=t?.args??[],[r,n]=e;return Ee({...t,args:[r,"multiply",n]})}function hh(t){let e=t?.args??[],[r,n]=e;return Ee({...t,args:[r,"divide",n]})}function E3(t){let e=t?.args??[],[r,n]=e;return Ee({...t,args:[r,"intDivide",n]})}function ph(t){let e=t?.args??[],[r,n]=e;return Ee({...t,args:[r,"power",n]})}function _3(t){let e=t?.args??[],[r,n]=e,i=(o,s)=>Ee({...t,args:[o,s]});if(!n)return i("round",r);switch(n){case"floor":return i("floor",r);case"ceil":return i("ceil",r);case"trunc":return i("trunc",r);default:throw new ge("Math: Unknown operation: "+I(n))}}function C3(t){let e=t?.args??[],[r]=e;return Ee({...t,args:["sqrt",r]})}function O3(t){let e=t?.args??[],[r]=e;return Ee({...t,args:["cbrt",r]})}function T3(t){let e=t?.args??[],[r]=e;return Ee({...t,args:["abs",r]})}var mh=te({helpers:{op:Ee,plus:w3,sum:S3,minus:$3,mul:fh,multiply:fh,div:hh,divide:hh,intDivide:E3,pow:ph,power:ph,round:_3,sqrt:C3,cbrt:O3,abs:T3,__default:Ee}});function gh(t){let e=t?.flext??{},r=t?.args??[],[n]=r,o=(e?.assets??{})[n]??null;if(o)return URL.createObjectURL(o);throw new ht(`Media: Unable to get the asset: Asset '${n}' does not exist`)}var bh=te({helpers:{url:gh,__default:gh}});var Wh=yn(qh(),1);var Vh={useLongScale:!1,baseSeparator:" ",unitSeparator:" ",base:{"0":"\u043D\u04E9\u043B","1":"\u0431\u0456\u0440","2":"\u0435\u043A\u0456","3":"\u04AF\u0448","4":"\u0442\u04E9\u0440\u0442","5":"\u0431\u0435\u0441","6":"\u0430\u043B\u0442\u044B","7":"\u0436\u0435\u0442\u0456","8":"\u0441\u0435\u0433\u0456\u0437","9":"\u0442\u043E\u0493\u044B\u0437","10":"\u043E\u043D","11":"\u043E\u043D \u0431\u0456\u0440","12":"\u043E\u043D \u0435\u043A\u0456","13":"\u043E\u043D \u04AF\u0448","14":"\u043E\u043D \u0442\u04E9\u0440\u0442","15":"\u043E\u043D \u0431\u0435\u0441","16":"\u043E\u043D \u0430\u043B\u0442\u044B","17":"\u043E\u043D \u0436\u0435\u0442\u0456","18":"\u043E\u043D \u0441\u0435\u0433\u0456\u0437","19":"\u043E\u043D \u0442\u043E\u0493\u044B\u0437","20":"\u0436\u0438\u044B\u0440\u043C\u0430","30":"\u043E\u0442\u044B\u0437","40":"\u049B\u044B\u0440\u044B\u049B","50":"\u0435\u043B\u0443","60":"\u0430\u043B\u043F\u044B\u0441","70":"\u0436\u0435\u0442\u043F\u0456\u0441","80":"\u0441\u0435\u043A\u0441\u0435\u043D","90":"\u0442\u043E\u049B\u0441\u0430\u043D","100":"\u0436\u04AF\u0437","200":"\u0435\u043A\u0456 \u0436\u04AF\u0437","300":"\u04AF\u0448 \u0436\u04AF\u0437","400":"\u0442\u04E9\u0440\u0442 \u0436\u04AF\u0437","500":"\u0431\u0435\u0441 \u0436\u04AF\u0437","600":"\u0430\u043B\u0442\u044B \u0436\u04AF\u0437","700":"\u0436\u0435\u0442\u0456 \u0436\u04AF\u0437","800":"\u0441\u0435\u0433\u0456\u0437 \u0436\u04AF\u0437","900":"\u0442\u043E\u0493\u044B\u0437 \u0436\u04AF\u0437"},alternativeBase:{},units:[{useBaseInstead:!0,useBaseException:[]},{singular:"\u043C\u044B\u04A3",plural:"\u043C\u044B\u04A3"},{singular:"\u043C\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u043C\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u043C\u0438\u043B\u043B\u0438\u0430\u0440\u0434",plural:"\u043C\u0438\u043B\u043B\u0438\u0430\u0440\u0434"},{singular:"\u0442\u0440\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u0442\u0440\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u043A\u0432\u0430\u0434\u0440\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u043A\u0432\u0430\u0434\u0440\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u043A\u0432\u0438\u043D\u0442\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u043A\u0432\u0438\u043D\u0442\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u0441\u0435\u043A\u0441\u0442\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u0441\u0435\u043A\u0441\u0442\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u0441\u0435\u043F\u0442\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u0441\u0435\u043F\u0442\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u043E\u043A\u0442\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u043E\u043A\u0442\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u043D\u043E\u043D\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u043D\u043E\u043D\u0438\u043B\u043B\u0438\u043E\u043D"},{singular:"\u0434\u0435\u0446\u0438\u043B\u043B\u0438\u043E\u043D",plural:"\u0434\u0435\u0446\u0438\u043B\u043B\u0438\u043E\u043D"}],unitExceptions:{"1000":"\u043C\u044B\u04A3"}};var jh={"ar-EG":"ar","az-AZ":"az","en-IN":"enIndian","en-GB":"uk","en-US":"en",eo:"eo","es-ES":"es","fr-FR":"fr","id-ID":"id","pt-BR":"pt","pt-PT":"ptPT","ru-RU":"ru","tr-TR":"tr","vi-VN":"vi"};var J3="en",X3={"kk-KZ":Vh};function Ki(t){let e=t?.flext??{},r=t?.args??[],n=t?.namedArgs??{},[i,o]=r,{lang:s,strict:a}=n,l=d=>jh[d]??X3[d]??null,c=l(s)??l(e?.lang)??J3;switch(i){case"text":return(0,Wh.default)(Number(o),{lang:c});case"check":return a?typeof o=="number":$e(o);default:return Number(i)}}function Q3(t){let e=t?.args??[],[r]=e;return String(Ki({...t,args:["text",r]}))}function e4(t){let e=t?.args??[],[r]=e;return Ki({...t,args:["check",r]})}var Bh=te({helpers:{op:Ki,text:Q3,check:e4,__default:Ki}});var qa=yn(pa(),1);var t4="text-blue-500";function Uh(t){let e=t?.args??[],[r,n]=e,i=gn(r,!1);return i&&!$e(r)&&!pe(r,!0,!1)?Ia(i):r??n??""}function r4(t){let r=(t?.namedArgs??{})?.color??t4;return r?new qa.SafeString(`<span class="${r}">${Uh(t)}</span>`):new qa.SafeString(t)}var Hh=te({helpers:{noColor:Uh,__default:r4}});function Ji(t){let e=t?.args??[],[r,n]=e;switch(r){case"json":return JSON.parse(n);case"check":return typeof n=="string";default:return r}}function n4(t){let e=t?.args??[],[r]=e;return Ji({...t,args:["json",r]})}function i4(t){let e=t?.args??[],[r]=e;return Ji({...t,args:["check",r]})}var Gh=te({helpers:{op:Ji,json:n4,check:i4,__default:Ji}});var o4="__default",Va=10,Qi=class{onGetProcessed=a4;onGetAst=Sa;constructor(e=null,r={},n={}){e&&this.setTemplate(e),this.setData({...this.data,...r}),this.setHelpers({...this.helpers,...n})}setTemplate(e){this.data={},this.helpers={};let r=this.onGetProcessed(e);return this.ast=this.onGetAst(r),this}setData(e){return this.data=e,this}setHelpers(e){return this.helpers=e,this}addHelper(e,r){return this.helpers[e]=r,this}setOnGetProcessed(e){return this.onGetProcessed=e,this}setOnGetAst(e){return this.onGetAst=e,this}getHtml(e,r){let n=Bi(this.ast);if(!n)throw new se("Flext: Unable to get HTML: No template");return Ui(n,e??this.data,r??this.helpers)}async getCss(e,r={}){let n=Bi(this.ast),i=r?.helpers??{},o={...this.helpers,...i};if(!n)throw new se("Flext: Unable to get CSS: No template");return await $a(n,e??this.data,{...r,helpers:o})}get html(){return this.getHtml()}},eo=class extends Qi{onGetTitle=Ca;onGetMacro=_a;constructor(e=null,r={},n={}){super(null,r,n),e&&this.setTemplate(e),this.setData({...this.data,...r}),this.setHelpers({...this.helpers,...n})}useModule(...e){for(let r of e)this.addModule(r,Xi[r]);return this}setTemplate(e){super.setTemplate(e);let[r]=this.onGetTitle(this.ast),n=this.onGetMacro(this.ast),{version:i,lang:o,timeZone:s,title:a,moduleNames:l,lineHeight:c,fields:d}=s4(n);return i&&this.setVersion(i),o&&this.setLang(o),s&&this.setTimeZone(s),(a||r)&&this.setTitle(a??Oa(r)),c&&this.setLineHeight(Number(c)),d&&d?.length&&this.setFields(d),this.useModule(...l),this}setVersion(e){return this.version=e,this}setLang(e){return this.lang=e,this}setTitle(e){return this.title=e,this}setTimeZone(e){return this.timeZone=e,this}setLineHeight(e){return this.lineHeight=e,this}setAssets(e){return this.assets=e,this}addAsset(e,r){return this.assets[e]=r,this}setFields(e){return this.fields=e,this}addModule(e,r){let n=r?.helpers??{};for(let i in n){if(!ji(n,i))continue;let o=n[i],s=i===o4,a=this,l=function(...c){let d=c?.slice(0,-1)??[],u=c[c.length-1]??{},h=u?.hash??{},p=this;return o({flext:a,args:d,options:u,namedArgs:h,self:p,getContent:()=>u?.fn(p)??null})};s?this.addHelper(e,l):this.addHelper(e+":"+i,l)}return this}setOnGetTitle(e){return this.onGetTitle=e,this}setOnGetMacro(e){return this.onGetMacro=e,this}getDataModel(e=Va){let r=a=>{for(let l in this.helpers)if(ji(this.helpers,l)){if(a?.name===l)return!0}else continue;return!1},n=a=>!r(a),i=a=>Hi(a,this.fields,{},e);return(Ea(this.ast)?.$??[]).filter(n).map(i)}getValidationErrors(e,r=Va){return Gi(e??this.data,this.model,r)}getIsValid(e,r=Va){return!this.getValidationErrors(e??this.data,r)?.length}get model(){return this.getDataModel()}get validationErrors(){return this.getValidationErrors()}get errors(){return this.validationErrors}get isValid(){return this.getIsValid()}};function s4(t){let e=(...b)=>t?.filter(k=>pe(k?.name,...b))??null,r=b=>{let[k]=e(b),[v]=k?.params??[];return v?.value??null},n=r("v"),i=r("lang"),o=r("title"),s=r("timeZone"),a=e("use"),l=r("lineHeight"),c=e("option"),d=e("group","field"),u=c?.map(Aa)??null,h=d?.map(Pa)??[];La(u,h),Da(h);let p=h.filter(b=>b?.extra?.macroName==="group");for(let b of p)b.type="object";let m=a.map(Na).flat();return{version:n,lang:i,timeZone:s,title:o,moduleNames:m,lineHeight:l,fields:h}}function a4(t){return t}var Bw=eo;export{se as BaseError,Ht as BaseThrowable,Ge as BaseWarning,eo as Flext,ft as PotentialLoopError,Qi as SimpleFlext,Gt as TemplateDataValidationError,ht as TemplateError,ge as TemplateSyntaxError,Bw as default,io as errors,za as lib,Xi as modules,ep as types};
|
|
567
567
|
//# sourceMappingURL=index.js.map
|