@antontranelis/money-printer 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +568 -464
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),ge=require("zustand"),fe=require("zustand/middleware"),b=require("react"),be=require("jspdf");var T=typeof document<"u"?document.currentScript:null;const J={personalInfo:{name:"",email:"",phone:""},voucherConfig:{hours:1,description:"",language:"de"},portrait:{original:null,enhanced:null,useEnhanced:!1,zoom:1},currentSide:"front",isEnhancing:!1,isExporting:!1},m=ge.create()(fe.persist(e=>({...J,setPersonalInfo:t=>e(a=>({personalInfo:{...a.personalInfo,...t}})),setVoucherConfig:t=>e(a=>({voucherConfig:{...a.voucherConfig,...t}})),setPortrait:(t,a=null)=>e({portrait:{original:t,enhanced:a,useEnhanced:!1,zoom:1}}),setEnhancedPortrait:t=>e(a=>({portrait:{...a.portrait,enhanced:t,useEnhanced:t!==null}})),toggleUseEnhanced:()=>e(t=>({portrait:{...t.portrait,useEnhanced:t.portrait.enhanced?!t.portrait.useEnhanced:!1}})),setPortraitZoom:t=>e(a=>({portrait:{...a.portrait,zoom:t}})),setCurrentSide:t=>e({currentSide:t}),flipSide:()=>e(t=>({currentSide:t.currentSide==="front"?"back":"front"})),setIsEnhancing:t=>e({isEnhancing:t}),setIsExporting:t=>e({isExporting:t}),setLanguage:t=>e(a=>({voucherConfig:{...a.voucherConfig,language:t}})),setHours:t=>e(a=>({voucherConfig:{...a.voucherConfig,hours:t}})),reset:()=>e(J)}),{name:"money-generator-storage",partialize:e=>({personalInfo:e.personalInfo,voucherConfig:e.voucherConfig})})),xe={header:{title:"Money Generator",subtitle:"Erstelle deinen persönlichen Zeitgutschein"},form:{personalInfo:{title:"Persönliche Daten",name:"Name",namePlaceholder:"Dein Name",email:"E-Mail",emailPlaceholder:"deine@email.de",phone:"Telefon",phonePlaceholder:"+49 123 456789"},portrait:{title:"Portrait",upload:"Bild hochladen",dragDrop:"oder hierher ziehen",enhance:"Mit AI verbessern",enhancing:"Wird verbessert...",useOriginal:"Original verwenden",useEnhanced:"Verbessertes verwenden",zoom:"Zoom"},voucher:{title:"Gutschein",hours:"Stunden",hourLabel:"Stunde",hoursLabel:"Stunden",description:"Beschreibung",descriptionPlaceholder:"Was kann mit diesem Gutschein eingelöst werden?"}},preview:{front:"Vorderseite",back:"Rückseite",flip:"Umdrehen"},export:{button:"Als PDF herunterladen",exporting:"PDF wird erstellt...",success:"Download gestartet!"},bill:{descriptionText:"Für diesen Schein erhältst du {hours} {hourLabel} meiner Zeit oder ein gleichwertiges Dankeschön"}},ye={header:{title:"Money Generator",subtitle:"Create your personal time voucher"},form:{personalInfo:{title:"Personal Information",name:"Name",namePlaceholder:"Your name",email:"Email",emailPlaceholder:"your@email.com",phone:"Phone",phonePlaceholder:"+1 234 567890"},portrait:{title:"Portrait",upload:"Upload image",dragDrop:"or drag and drop",enhance:"Enhance with AI",enhancing:"Enhancing...",useOriginal:"Use original",useEnhanced:"Use enhanced",zoom:"Zoom"},voucher:{title:"Voucher",hours:"Hours",hourLabel:"hour",hoursLabel:"hours",description:"Description",descriptionPlaceholder:"What can be redeemed with this voucher?"}},preview:{front:"Front",back:"Back",flip:"Flip"},export:{button:"Download as PDF",exporting:"Creating PDF...",success:"Download started!"},bill:{descriptionText:"This voucher entitles you to {hours} {hourLabel} of my time or an equivalent thank you"}},ve={de:xe,en:ye};function E(e){return ve[e]}function K(e,t,a){if(a&&a.trim())return a;const r=E(e),o=t===1?r.form.voucher.hourLabel:r.form.voucher.hoursLabel;return r.bill.descriptionText.replace("{hours}",t.toString()).replace("{hourLabel}",o)}function we(){const e=m(o=>o.voucherConfig.language),t=m(o=>o.personalInfo),a=m(o=>o.setPersonalInfo),r=E(e);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"form-control",children:[n.jsx("label",{className:"label",children:n.jsx("span",{className:"label-text font-medium",children:r.form.personalInfo.name})}),n.jsx("input",{type:"text",placeholder:r.form.personalInfo.namePlaceholder,className:"input input-bordered w-full",value:t.name,onChange:o=>a({name:o.target.value})})]}),n.jsxs("div",{className:"form-control",children:[n.jsx("label",{className:"label",children:n.jsx("span",{className:"label-text font-medium",children:r.form.personalInfo.email})}),n.jsx("input",{type:"email",placeholder:r.form.personalInfo.emailPlaceholder,className:"input input-bordered w-full",value:t.email,onChange:o=>a({email:o.target.value})})]}),n.jsxs("div",{className:"form-control",children:[n.jsx("label",{className:"label",children:n.jsx("span",{className:"label-text font-medium",children:r.form.personalInfo.phone})}),n.jsx("input",{type:"tel",placeholder:r.form.personalInfo.phonePlaceholder,className:"input input-bordered w-full",value:t.phone,onChange:o=>a({phone:o.target.value})})]})]})}const F={},ke="https://api.stability.ai/v1/generation",je={vintage:"portrait in the style of vintage currency engraving, fine line work, crosshatching, sepia tones, detailed stippling, classic bank note portrait style",engraved:"portrait as detailed intaglio engraving, currency bill style, fine parallel lines, high contrast, official government portrait",currency:"portrait rendered as US dollar bill engraving, official currency portrait style, green tint, fine line engraving technique"};function Pe(e){var l;const t=e.split(","),a=((l=t[0].match(/:(.*?);/))==null?void 0:l[1])||"image/png",r=atob(t[1]),o=r.length,s=new Uint8Array(o);for(let d=0;d<o;d++)s[d]=r.charCodeAt(d);return new Blob([s],{type:a})}function W(){var t;const e=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:T&&T.tagName.toUpperCase()==="SCRIPT"&&T.src||new URL("index.cjs",document.baseURI).href}<"u"&&(F==null?void 0:F.VITE_STABILITY_API_KEY)||typeof process<"u"&&((t=process.env)==null?void 0:t.NEXT_PUBLIC_STABILITY_API_KEY);return e&&e!=="your-api-key-here"?e:typeof localStorage<"u"?localStorage.getItem("stability_api_key"):null}function ee(e){localStorage.setItem("stability_api_key",e)}function M(){return W()!==null}async function te(e){const t=W();if(!t)throw new Error("No Stability AI API key configured");const{imageDataUrl:a,style:r,strength:o=.35}=e,s=Pe(a),l=new FormData;l.append("init_image",s,"portrait.png"),l.append("init_image_mode","IMAGE_STRENGTH"),l.append("image_strength",String(1-o)),l.append("text_prompts[0][text]",je[r]),l.append("text_prompts[0][weight]","1"),l.append("cfg_scale","7"),l.append("samples","1"),l.append("steps","30");const i=await fetch(`${ke}/stable-diffusion-xl-1024-v1-0/image-to-image`,{method:"POST",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"},body:l});if(!i.ok){const g=await i.text();throw console.error("Stability AI error:",g),i.status===401?new Error("Invalid API key"):i.status===402?new Error("Insufficient credits"):i.status===429?new Error("Rate limit exceeded. Please try again later."):new Error(`API error: ${i.status}`)}const c=await i.json();if(!c.artifacts||c.artifacts.length===0)throw new Error("No image generated");return`data:image/png;base64,${c.artifacts[0].base64}`}async function H(e){return new Promise((t,a)=>{const r=new Image;r.onload=()=>{const o=document.createElement("canvas"),s=o.getContext("2d");if(!s){a(new Error("Failed to get canvas context"));return}o.width=r.width,o.height=r.height,s.filter="sepia(0.3) contrast(1.1) saturate(0.9)",s.drawImage(r,0,0),t(o.toDataURL("image/png"))},r.onerror=()=>a(new Error("Failed to load image")),r.src=e})}function Ie(){const[e,t]=b.useState(!1),[a,r]=b.useState(null),[o,s]=b.useState(M()),l=b.useCallback(()=>r(null),[]),d=b.useCallback(c=>{ee(c),s(!0),r(null)},[]);return{enhance:b.useCallback(async(c,g="vintage")=>{t(!0),r(null);try{return M()?await te({imageDataUrl:c,style:g,strength:.35}):await H(c)}catch(p){const f=p instanceof Error?p.message:"Enhancement failed";if(r(f),f.includes("API")||f.includes("key"))try{return await H(c)}catch{throw p}throw p}finally{t(!1)}},[]),isEnhancing:e,error:a,hasKey:o,setApiKey:d,clearError:l}}function ne({isOpen:e,onClose:t,onSubmit:a}){const r=m(c=>c.voucherConfig.language),[o,s]=b.useState("");if(!e)return null;const l=c=>{c.preventDefault(),o.trim()&&(a(o.trim()),s(""),t())},i={de:{title:"Stability AI API Key",description:"Um die AI-Bildverbesserung zu nutzen, benötigst du einen Stability AI API Key. Du kannst ihn auf platform.stability.ai erhalten.",placeholder:"sk-...",submit:"Speichern",cancel:"Abbrechen",hint:"Der Key wird lokal in deinem Browser gespeichert."},en:{title:"Stability AI API Key",description:"To use AI image enhancement, you need a Stability AI API key. You can get one at platform.stability.ai.",placeholder:"sk-...",submit:"Save",cancel:"Cancel",hint:"The key is stored locally in your browser."}}[r];return n.jsxs("dialog",{className:"modal modal-open",children:[n.jsxs("div",{className:"modal-box",children:[n.jsx("h3",{className:"font-bold text-lg",children:i.title}),n.jsx("p",{className:"py-4 text-sm opacity-80",children:i.description}),n.jsxs("form",{onSubmit:l,children:[n.jsxs("div",{className:"form-control",children:[n.jsx("input",{type:"password",placeholder:i.placeholder,className:"input input-bordered w-full",value:o,onChange:c=>s(c.target.value),autoFocus:!0}),n.jsx("label",{className:"label",children:n.jsx("span",{className:"label-text-alt",children:i.hint})})]}),n.jsxs("div",{className:"modal-action",children:[n.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t,children:i.cancel}),n.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!o.trim(),children:i.submit})]})]})]}),n.jsx("form",{method:"dialog",className:"modal-backdrop",children:n.jsx("button",{onClick:t,children:"close"})})]})}function Ne(){const e=m(u=>u.voucherConfig.language),t=m(u=>u.portrait),a=m(u=>u.setPortrait),r=m(u=>u.setEnhancedPortrait),o=m(u=>u.toggleUseEnhanced),s=m(u=>u.setPortraitZoom),{enhance:l,isEnhancing:d,error:i,hasKey:c,setApiKey:g}=Ie(),p=E(e),f=b.useRef(null),[x,h]=b.useState(!1),[I,j]=b.useState(!1),k=b.useCallback(u=>{if(!u.type.startsWith("image/"))return;const v=new FileReader;v.onload=_=>{var X;const me=(X=_.target)==null?void 0:X.result;a(me)},v.readAsDataURL(u)},[a]),S=b.useCallback(u=>{u.preventDefault(),h(!1);const v=u.dataTransfer.files[0];v&&k(v)},[k]),y=b.useCallback(u=>{u.preventDefault(),h(!0)},[]),P=b.useCallback(u=>{u.preventDefault(),h(!1)},[]),L=()=>{var u;(u=f.current)==null||u.click()},A=u=>{var _;const v=(_=u.target.files)==null?void 0:_[0];v&&k(v)},$=async()=>{if(t.original){if(!c){j(!0);return}try{const u=await l(t.original,"vintage");r(u)}catch(u){console.error("Enhancement failed:",u)}}},U=async u=>{if(g(u),t.original)try{const v=await l(t.original,"vintage");r(v)}catch(v){console.error("Enhancement failed:",v)}},pe=()=>{a(null)},he=t.useEnhanced&&t.enhanced?t.enhanced:t.original;return n.jsxs("div",{className:"space-y-4",children:[t.original?n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex justify-center",children:n.jsxs("div",{className:"relative",children:[n.jsx("div",{className:"w-32 h-32 rounded-full overflow-hidden border-4 border-currency-gold shadow-lg",children:n.jsx("img",{src:he||"",alt:"Portrait",className:"w-full h-full object-cover",style:{transform:`scale(${t.zoom})`}})}),n.jsx("button",{className:"btn btn-circle btn-xs btn-error absolute -top-1 -right-1",onClick:pe,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),n.jsxs("div",{className:"form-control",children:[n.jsxs("label",{className:"label",children:[n.jsx("span",{className:"label-text",children:p.form.portrait.zoom}),n.jsxs("span",{className:"label-text-alt",children:[Math.round(t.zoom*100),"%"]})]}),n.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:t.zoom,onChange:u=>s(parseFloat(u.target.value)),className:"range range-primary range-sm"})]}),c&&n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("button",{className:`btn btn-secondary ${d?"loading":""}`,onClick:$,disabled:d,children:d?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"loading loading-spinner loading-sm"}),p.form.portrait.enhancing]}):n.jsxs(n.Fragment,{children:[n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),p.form.portrait.enhance]})}),i&&n.jsxs("div",{className:"alert alert-warning text-sm py-2",children:[n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stroke-current shrink-0 h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),n.jsx("span",{children:i})]}),t.enhanced&&n.jsx("div",{className:"form-control",children:n.jsxs("label",{className:"label cursor-pointer justify-start gap-3",children:[n.jsx("input",{type:"checkbox",className:"toggle toggle-primary",checked:t.useEnhanced,onChange:o}),n.jsx("span",{className:"label-text",children:t.useEnhanced?p.form.portrait.useEnhanced:p.form.portrait.useOriginal})]})})]})]}):n.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${x?"border-primary bg-primary/10":"border-base-300 hover:border-primary hover:bg-base-200"}`,onDrop:S,onDragOver:y,onDragLeave:P,onClick:L,children:[n.jsx("input",{ref:f,type:"file",accept:"image/*",className:"hidden",onChange:A}),n.jsxs("div",{className:"flex flex-col items-center gap-2",children:[n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-12 w-12 text-base-content/50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),n.jsx("p",{className:"font-medium",children:p.form.portrait.upload}),n.jsx("p",{className:"text-sm text-base-content/60",children:p.form.portrait.dragDrop})]})]}),n.jsx(ne,{isOpen:I,onClose:()=>j(!1),onSubmit:U})]})}function Ce(){return null}const w=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:T&&T.tagName.toUpperCase()==="SCRIPT"&&T.src||new URL("index.cjs",document.baseURI).href}<"u"&&"/"||"/",ae={en:{1:{front:`${w}templates/front_ldpi_en.png`,back:`${w}templates/back_ldpi_en.png`,width:1536,height:1024},5:{front:`${w}templates/front_ldpi_en.png`,back:`${w}templates/back_ldpi_en.png`,width:1536,height:1024},10:{front:`${w}templates/front_ldpi_en.png`,back:`${w}templates/back_ldpi_en.png`,width:1536,height:1024}},de:{1:{front:`${w}templates/front_hdpi_de.webp`,back:`${w}templates/back_hdpi_de.webp`,width:6144,height:3200},5:{front:`${w}templates/front_hdpi_de.webp`,back:`${w}templates/back_hdpi_de.webp`,width:6144,height:3200},10:{front:`${w}templates/front_hdpi_de.webp`,back:`${w}templates/back_hdpi_de.webp`,width:6144,height:3200}}},N={front:{portrait:{x:768,y:490,radiusX:236,radiusY:258},namePlate:{x:768,y:848,fontSize:36,maxWidth:380,align:"center"}},back:{portrait:{x:0,y:0,radiusX:0,radiusY:0},namePlate:{x:768,y:832,fontSize:36,maxWidth:380,align:"center"},contactInfo:{x:380,y:500,fontSize:38,lineHeight:55,align:"center"},description:{x:1150,y:500,fontSize:38,maxWidth:480,lineHeight:42,align:"center"}}},C={front:{portrait:{x:3074,y:1530,radiusX:942,radiusY:1020},namePlate:{x:3072,y:2950,fontSize:144,maxWidth:1520,align:"center"}},back:{portrait:{x:0,y:0,radiusX:0,radiusY:0},namePlate:{x:3072,y:2930,fontSize:144,maxWidth:1520,align:"center"},contactInfo:{x:1520,y:1680,fontSize:160,lineHeight:280,align:"center"},description:{x:4600,y:1680,fontSize:145,maxWidth:2e3,lineHeight:210,align:"center"}}};function O(e){return e==="de"?C:N}function q(e,t){return ae[e][t]}const z=new Map;async function D(e){return z.has(e)?z.get(e):new Promise((t,a)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{z.set(e,r),t(r)},r.onerror=a,r.src=e})}function Y(e,t,a,r){e.drawImage(t,0,0,a,r)}function re(e,t,a,r,o,s,l=1){e.save(),e.beginPath(),e.ellipse(a,r,o,s,0,0,Math.PI*2),e.closePath(),e.clip();const d=t.width/t.height,i=o/s,c=o*2,g=s*2;let p,f;d>i?(f=g,p=g*d):(p=c,f=c/d),p*=l,f*=l;const x=a-p/2,h=r-f/2;e.drawImage(t,x,h,p,f),e.restore()}function V(e,t,a,r="#2a3a2a"){e.save(),e.font=`${a.fontSize}px "Times New Roman", serif`,e.textAlign=a.align||"center",e.textBaseline="middle",e.fillStyle=r,a.maxWidth?e.fillText(t,a.x,a.y,a.maxWidth):e.fillText(t,a.x,a.y),e.restore()}function oe(e,t,a,r="#2a3a2a"){e.save(),e.font=`${a.fontSize}px "Times New Roman", serif`,e.textAlign=a.align||"center",e.textBaseline="top",e.fillStyle=r;const o=a.maxWidth||400,s=a.lineHeight||a.fontSize*1.4,l=t.split(" "),d=[];let i="";for(const p of l){const f=i?`${i} ${p}`:p;e.measureText(f).width>o&&i?(d.push(i),i=p):i=f}i&&d.push(i);const c=d.length*s;let g=a.y-c/2;for(const p of d)e.fillText(p,a.x,g),g+=s;e.restore()}function ie(e,t,a,r,o,s="#2a3a2a"){e.save(),e.font=`${o.fontSize}px "Times New Roman", serif`,e.textAlign=o.align||"center",e.textBaseline="middle",e.fillStyle=s;const l=o.lineHeight||o.fontSize*1.8,d=[t,a,r].filter(Boolean),i=(d.length-1)*l;let c=o.y-i/2;for(const g of d)g&&(e.fillText(g,o.x,c),c+=l);e.restore()}async function Z(e,t,a,r,o,s,l,d=1){const i=e.getContext("2d");if(!i)return;e.width=s,e.height=l,i.clearRect(0,0,s,l);const c=await D(t);if(Y(i,c,s,l),a)try{const g=await D(a);re(i,g,o.portrait.x,o.portrait.y,o.portrait.radiusX,o.portrait.radiusY,d)}catch(g){console.error("Failed to load portrait:",g)}r&&V(i,r,o.namePlate)}async function G(e,t,a,r,o,s,l,d,i){const c=e.getContext("2d");if(!c)return;e.width=d,e.height=i,c.clearRect(0,0,d,i);const g=await D(t);Y(c,g,d,i),l.contactInfo&&(a||r||o)&&ie(c,a,r,o,l.contactInfo),l.description&&s&&oe(c,s,l.description),a&&V(c,a,l.namePlate)}function Ee(){const e=m(y=>y.voucherConfig.language),t=m(y=>y.voucherConfig.hours),a=m(y=>y.voucherConfig.description),r=m(y=>y.personalInfo),o=m(y=>y.portrait),s=m(y=>y.currentSide),l=m(y=>y.flipSide),d=E(e),i=b.useRef(null),c=b.useRef(null),g=b.useRef(null),[p,f]=b.useState(!1),x=q(e,t),h=O(e),I=o.useEnhanced&&o.enhanced?o.enhanced:o.original,j=K(e,t,a);b.useEffect(()=>{i.current&&Z(i.current,x.front,I,r.name,h.front,x.width,x.height,o.zoom)},[x,I,r.name,h,o.zoom]),b.useEffect(()=>{c.current&&G(c.current,x.back,r.name,r.email,r.phone,j,h.back,x.width,x.height)},[x,r,j,h]);const k=()=>{f(!0),setTimeout(()=>{l(),f(!1)},150)},S=x.width/x.height;return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex justify-between items-center",children:[n.jsxs("div",{className:"tabs tabs-boxed bg-base-200",children:[n.jsx("button",{className:`tab ${s==="front"?"tab-active bg-primary text-primary-content font-semibold":""}`,onClick:()=>s!=="front"&&k(),children:d.preview.front}),n.jsx("button",{className:`tab ${s==="back"?"tab-active bg-primary text-primary-content font-semibold":""}`,onClick:()=>s!=="back"&&k(),children:d.preview.back})]}),n.jsxs("button",{className:"btn btn-ghost btn-sm",onClick:k,children:[n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),d.preview.flip]})]}),n.jsxs("div",{ref:g,className:"relative w-full overflow-hidden shadow-lg",style:{aspectRatio:S},children:[n.jsx("canvas",{ref:i,className:`absolute inset-0 w-full h-full transition-all duration-300 ${s==="front"?p?"opacity-0 scale-95":"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"}`}),n.jsx("canvas",{ref:c,className:`absolute inset-0 w-full h-full transition-all duration-300 ${s==="back"?p?"opacity-0 scale-95":"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"}`})]})]})}function Se(){const e=b.useRef(null),t=b.useRef(null);return{frontCanvasRef:e,backCanvasRef:t}}async function se(e){const{frontTemplateSrc:t,backTemplateSrc:a,templateWidth:r,templateHeight:o,layout:s,portrait:l,portraitZoom:d=1,name:i,email:c,phone:g,description:p}=e,f=document.createElement("canvas"),x=document.createElement("canvas");await Promise.all([Z(f,t,l,i,s.front,r,o,d),G(x,a,i,c,g,p,s.back,r,o)]);const h=new be({orientation:"landscape",unit:"mm",format:"a4"}),I=297,j=210,k=10,S=r/o;let y=I-k*2,P=y/S;P>j-k*2&&(P=j-k*2,y=P*S);const L=(I-y)/2,A=(j-P)/2,$=f.toDataURL("image/jpeg",.95);h.addImage($,"JPEG",L,A,y,P),h.addPage();const U=x.toDataURL("image/jpeg",.95);return h.addImage(U,"JPEG",L,A,y,P),h.output("blob")}function le(e,t){const a=URL.createObjectURL(e),r=document.createElement("a");r.href=a,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)}async function ce(e){const t=await se(e);le(t,e.filename)}function Te(){const e=m(h=>h.voucherConfig.language),t=m(h=>h.voucherConfig.hours),a=m(h=>h.voucherConfig.description),r=m(h=>h.personalInfo),o=m(h=>h.portrait),s=m(h=>h.isExporting),l=m(h=>h.setIsExporting),d=E(e),i=q(e,t),c=O(e),g=o.useEnhanced&&o.enhanced?o.enhanced:o.original,p=K(e,t,a),f=r.name.trim().length>0&&r.email.trim().length>0&&r.phone.trim().length>0&&o.original!==null,x=async()=>{if(!(!f||s)){l(!0);try{const h=`zeitgutschein-${t}h-${r.name.replace(/\s+/g,"-").toLowerCase()}.pdf`;await ce({frontTemplateSrc:i.front,backTemplateSrc:i.back,templateWidth:i.width,templateHeight:i.height,layout:c,portrait:g,portraitZoom:o.zoom,name:r.name,email:r.email,phone:r.phone,description:p,filename:h})}catch(h){console.error("PDF export failed:",h)}finally{l(!1)}}};return n.jsx("button",{className:`btn btn-primary flex-1 ${s?"loading":""}`,onClick:x,disabled:!f||s,children:s?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"loading loading-spinner loading-sm"}),d.export.exporting]}):n.jsxs(n.Fragment,{children:[n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),d.export.button]})})}function de(){const e=m(r=>r.voucherConfig.language),t=m(r=>r.setLanguage),a=r=>{t(r)};return n.jsxs("div",{className:"join",children:[n.jsx("button",{className:`join-item btn btn-sm ${e==="de"?"btn-active btn-primary":"btn-ghost"}`,onClick:()=>a("de"),children:"DE"}),n.jsx("button",{className:`join-item btn btn-sm ${e==="en"?"btn-active btn-primary":"btn-ghost"}`,onClick:()=>a("en"),children:"EN"})]})}function Le(){const e=m(a=>a.voucherConfig.language),t=E(e);return n.jsxs("div",{className:"navbar bg-currency-green text-currency-cream shadow-lg",children:[n.jsx("div",{className:"navbar-start",children:n.jsx("a",{className:"btn btn-ghost text-xl font-currency font-bold",children:t.header.title})}),n.jsx("div",{className:"navbar-center hidden sm:flex",children:n.jsx("span",{className:"text-sm opacity-80",children:t.header.subtitle})}),n.jsx("div",{className:"navbar-end",children:n.jsx(de,{})})]})}const R="/",Ae={id:"time-voucher-classic-de",name:"Zeitgutschein Classic",type:"time-voucher",category:"classic",images:{front:`${R}templates/front_hdpi_de.jpg`,back:`${R}templates/back_hdpi_de.jpg`,width:6144,height:4096},fields:[{id:"name",type:"text",label:{de:"Name",en:"Name"},required:!0,validation:{minLength:1,maxLength:50}},{id:"hours",type:"select",label:{de:"Stunden",en:"Hours"},required:!0,options:["1","5","10"]},{id:"portrait",type:"image",label:{de:"Portrait",en:"Portrait"},required:!1},{id:"email",type:"text",label:{de:"E-Mail",en:"Email"},required:!1},{id:"phone",type:"text",label:{de:"Telefon",en:"Phone"},required:!1},{id:"description",type:"textarea",label:{de:"Beschreibung",en:"Description"},required:!1,validation:{maxLength:200}}],layout:{front:{portrait:C.front.portrait,name:C.front.namePlate},back:{name:C.back.namePlate,contactInfo:C.back.contactInfo,description:C.back.description}},languages:["de"]},_e={id:"time-voucher-classic-en",name:"Time Voucher Classic",type:"time-voucher",category:"classic",images:{front:`${R}templates/front_ldpi_en.png`,back:`${R}templates/back_ldpi_en.png`,width:1536,height:1024},fields:[{id:"name",type:"text",label:{de:"Name",en:"Name"},required:!0,validation:{minLength:1,maxLength:50}},{id:"hours",type:"select",label:{de:"Stunden",en:"Hours"},required:!0,options:["1","5","10"]},{id:"portrait",type:"image",label:{de:"Portrait",en:"Portrait"},required:!1},{id:"email",type:"text",label:{de:"E-Mail",en:"Email"},required:!1},{id:"phone",type:"text",label:{de:"Telefon",en:"Phone"},required:!1},{id:"description",type:"textarea",label:{de:"Beschreibung",en:"Description"},required:!1,validation:{maxLength:200}}],layout:{front:{portrait:N.front.portrait,name:N.front.namePlate},back:{name:N.back.namePlate,contactInfo:N.back.contactInfo,description:N.back.description}},languages:["en"]},Q=[Ae,_e],ue={async listTemplates(e){let t=[...Q];return e!=null&&e.type&&(t=t.filter(a=>a.type===e.type)),e!=null&&e.category&&(t=t.filter(a=>a.category===e.category)),e!=null&&e.language&&(t=t.filter(a=>a.languages.includes(e.language))),t},async getTemplate(e){const t=Q.find(a=>a.id===e);if(!t)throw new Error(`Template not found: ${e}`);return t}};function De(e){return e==="de"?"time-voucher-classic-de":"time-voucher-classic-en"}let B=ue;function Re(e){B=e}function Be(){return B}async function $e(e){return B.listTemplates(e)}async function Ue(e){return B.getTemplate(e)}exports.ApiKeyModal=ne;exports.BillPreview=Ee;exports.ExportButton=Te;exports.Header=Le;exports.LAYOUT_HDPI=C;exports.LAYOUT_LDPI=N;exports.LanguageToggle=de;exports.PersonalInfoForm=we;exports.PortraitUpload=Ne;exports.TEMPLATES=ae;exports.VoucherConfig=Ce;exports.downloadBlob=le;exports.drawContactInfo=ie;exports.drawMultilineText=oe;exports.drawOvalPortrait=re;exports.drawTemplate=Y;exports.drawText=V;exports.enhancePortrait=te;exports.enhancePortraitFallback=H;exports.exportBillAsPDF=ce;exports.formatDescription=K;exports.generateBillPDF=se;exports.getApiKey=W;exports.getDefaultTemplateId=De;exports.getLayout=O;exports.getTemplate=q;exports.getTemplateById=Ue;exports.getTemplateProvider=Be;exports.hasApiKey=M;exports.listTemplates=$e;exports.loadImage=D;exports.renderBackSide=G;exports.renderFrontSide=Z;exports.setApiKey=ee;exports.setTemplateProvider=Re;exports.staticTemplateProvider=ue;exports.t=E;exports.useBillCanvasRefs=Se;exports.useBillStore=m;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),Ee=require("zustand"),Se=require("zustand/middleware"),f=require("react"),Ne=require("jspdf");var E=typeof document<"u"?document.currentScript:null;const te={personalInfo:{name:"",email:"",phone:""},voucherConfig:{hours:1,description:"",language:"de"},portrait:{original:null,enhanced:null,useEnhanced:!1,zoom:1},currentSide:"front",isEnhancing:!1,isExporting:!1},g=Ee.create()(Se.persist(e=>({...te,setPersonalInfo:t=>e(a=>({personalInfo:{...a.personalInfo,...t}})),setVoucherConfig:t=>e(a=>({voucherConfig:{...a.voucherConfig,...t}})),setPortrait:(t,a=null)=>e({portrait:{original:t,enhanced:a,useEnhanced:!1,zoom:1}}),setEnhancedPortrait:t=>e(a=>({portrait:{...a.portrait,enhanced:t,useEnhanced:t!==null}})),toggleUseEnhanced:()=>e(t=>({portrait:{...t.portrait,useEnhanced:t.portrait.enhanced?!t.portrait.useEnhanced:!1}})),setPortraitZoom:t=>e(a=>({portrait:{...a.portrait,zoom:t}})),setCurrentSide:t=>e({currentSide:t}),flipSide:()=>e(t=>({currentSide:t.currentSide==="front"?"back":"front"})),setIsEnhancing:t=>e({isEnhancing:t}),setIsExporting:t=>e({isExporting:t}),setLanguage:t=>e(a=>({voucherConfig:{...a.voucherConfig,language:t}})),setHours:t=>e(a=>({voucherConfig:{...a.voucherConfig,hours:t}})),reset:()=>e(te)}),{name:"money-generator-storage",partialize:e=>({personalInfo:e.personalInfo,voucherConfig:e.voucherConfig})})),Te={header:{title:"Money Generator",subtitle:"Erstelle deinen persönlichen Zeitgutschein"},form:{personalInfo:{title:"Persönliche Daten",name:"Name",namePlaceholder:"Dein Name",email:"E-Mail",emailPlaceholder:"deine@email.de",phone:"Telefon",phonePlaceholder:"+49 123 456789"},portrait:{title:"Portrait",upload:"Bild hochladen",dragDrop:"oder hierher ziehen",enhance:"Mit AI verbessern",enhancing:"Wird verbessert...",useOriginal:"Original verwenden",useEnhanced:"Verbessertes verwenden",zoom:"Zoom"},voucher:{title:"Gutschein",hours:"Stunden",hourLabel:"Stunde",hoursLabel:"Stunden",description:"Beschreibung",descriptionPlaceholder:"Was kann mit diesem Gutschein eingelöst werden?"}},preview:{front:"Vorderseite",back:"Rückseite",flip:"Umdrehen"},export:{button:"Als PDF herunterladen",exporting:"PDF wird erstellt...",success:"Download gestartet!"},bill:{descriptionText:"Für diesen Schein erhältst du {hours} {hourLabel} meiner Zeit oder ein gleichwertiges Dankeschön"}},Le={header:{title:"Money Generator",subtitle:"Create your personal time voucher"},form:{personalInfo:{title:"Personal Information",name:"Name",namePlaceholder:"Your name",email:"Email",emailPlaceholder:"your@email.com",phone:"Phone",phonePlaceholder:"+1 234 567890"},portrait:{title:"Portrait",upload:"Upload image",dragDrop:"or drag and drop",enhance:"Enhance with AI",enhancing:"Enhancing...",useOriginal:"Use original",useEnhanced:"Use enhanced",zoom:"Zoom"},voucher:{title:"Voucher",hours:"Hours",hourLabel:"hour",hoursLabel:"hours",description:"Description",descriptionPlaceholder:"What can be redeemed with this voucher?"}},preview:{front:"Front",back:"Back",flip:"Flip"},export:{button:"Download as PDF",exporting:"Creating PDF...",success:"Download started!"},bill:{descriptionText:"This voucher entitles you to {hours} {hourLabel} of my time or an equivalent thank you"}},Ae={de:Te,en:Le};function T(e){return Ae[e]}function W(e,t,a){if(a&&a.trim())return a;const n=T(e),o=t===1?n.form.voucher.hourLabel:n.form.voucher.hoursLabel;return n.bill.descriptionText.replace("{hours}",t.toString()).replace("{hourLabel}",o)}function Re(){const e=g(o=>o.voucherConfig.language),t=g(o=>o.personalInfo),a=g(o=>o.setPersonalInfo),n=T(e);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"form-control",children:[r.jsx("label",{className:"label",children:r.jsx("span",{className:"label-text font-medium",children:n.form.personalInfo.name})}),r.jsx("input",{type:"text",placeholder:n.form.personalInfo.namePlaceholder,className:"input input-bordered w-full",value:t.name,onChange:o=>a({name:o.target.value})})]}),r.jsxs("div",{className:"form-control",children:[r.jsx("label",{className:"label",children:r.jsx("span",{className:"label-text font-medium",children:n.form.personalInfo.email})}),r.jsx("input",{type:"email",placeholder:n.form.personalInfo.emailPlaceholder,className:"input input-bordered w-full",value:t.email,onChange:o=>a({email:o.target.value})})]}),r.jsxs("div",{className:"form-control",children:[r.jsx("label",{className:"label",children:r.jsx("span",{className:"label-text font-medium",children:n.form.personalInfo.phone})}),r.jsx("input",{type:"tel",placeholder:n.form.personalInfo.phonePlaceholder,className:"input input-bordered w-full",value:t.phone,onChange:o=>a({phone:o.target.value})})]})]})}const L={},De="https://api.stability.ai/v1/generation",_e="https://clipdrop-api.co/remove-background/v1",re="stability_api_key",oe="clipdrop_api_key",Be={vintage:"portrait in the style of vintage currency engraving, fine line work, crosshatching, sepia tones, detailed stippling, classic bank note portrait style",engraved:"portrait as detailed intaglio engraving, currency bill style, fine parallel lines, high contrast, official government portrait",currency:"portrait rendered as US dollar bill engraving, official currency portrait style, green tint, fine line engraving technique"},ne=[{width:1024,height:1024},{width:1152,height:896},{width:1216,height:832},{width:1344,height:768},{width:1536,height:640},{width:640,height:1536},{width:768,height:1344},{width:832,height:1216},{width:896,height:1152}];function Ue(e,t){const a=e/t;let n=ne[0],o=1/0;for(const i of ne){const d=i.width/i.height,l=Math.abs(a-d);l<o&&(o=l,n=i)}return n}function Ke(e){return new Promise((t,a)=>{const n=new Image;n.onload=()=>{const o=Ue(n.width,n.height),i=document.createElement("canvas");i.width=o.width,i.height=o.height;const d=i.getContext("2d");if(!d){a(new Error("Failed to get canvas context"));return}const l=n.width/n.height,s=o.width/o.height;let c=0,p=0,m=n.width,b=n.height;l>s?(m=n.height*s,c=(n.width-m)/2):(b=n.width/s,p=(n.height-b)/2),d.drawImage(n,c,p,m,b,0,0,o.width,o.height),t(i.toDataURL("image/png"))},n.onerror=()=>a(new Error("Failed to load image")),n.src=e})}function ie(e){var d;const t=e.split(","),a=((d=t[0].match(/:(.*?);/))==null?void 0:d[1])||"image/png",n=atob(t[1]),o=n.length,i=new Uint8Array(o);for(let l=0;l<o;l++)i[l]=n.charCodeAt(l);return new Blob([i],{type:a})}function Y(){var t;const e=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:E&&E.tagName.toUpperCase()==="SCRIPT"&&E.src||new URL("index.cjs",document.baseURI).href}<"u"&&(L==null?void 0:L.VITE_STABILITY_API_KEY)||typeof process<"u"&&((t=process.env)==null?void 0:t.NEXT_PUBLIC_STABILITY_API_KEY);return e&&e!=="your-api-key-here"?e:typeof localStorage<"u"?localStorage.getItem(re):null}function se(e){localStorage.setItem(re,e)}function M(){return Y()!==null}function q(){var t;const e=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:E&&E.tagName.toUpperCase()==="SCRIPT"&&E.src||new URL("index.cjs",document.baseURI).href}<"u"&&(L==null?void 0:L.VITE_CLIPDROP_API_KEY)||typeof process<"u"&&((t=process.env)==null?void 0:t.NEXT_PUBLIC_CLIPDROP_API_KEY);return e&&e!=="your-api-key-here"?e:typeof localStorage<"u"?localStorage.getItem(oe):null}function le(e){localStorage.setItem(oe,e)}function ce(){return q()!==null}async function de(e){const t=Y();if(!t)throw new Error("No Stability AI API key configured");const{imageDataUrl:a,style:n,strength:o=.35}=e,i=await Ke(a),d=ie(i),l=new FormData;l.append("init_image",d,"portrait.png"),l.append("init_image_mode","IMAGE_STRENGTH"),l.append("image_strength",String(1-o)),l.append("text_prompts[0][text]",Be[n]),l.append("text_prompts[0][weight]","1"),l.append("cfg_scale","7"),l.append("samples","1"),l.append("steps","30");const c=await fetch(`${De}/stable-diffusion-xl-1024-v1-0/image-to-image`,{method:"POST",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"},body:l});if(!c.ok){const m=await c.text();throw console.error("Stability AI error:",m),c.status===401?new Error("Invalid API key"):c.status===402?new Error("Insufficient credits"):c.status===429?new Error("Rate limit exceeded. Please try again later."):new Error(`API error: ${c.status}`)}const p=await c.json();if(!p.artifacts||p.artifacts.length===0)throw new Error("No image generated");return`data:image/png;base64,${p.artifacts[0].base64}`}async function he(e){const t=q();if(!t)throw new Error("No Clipdrop API key configured");const a=ie(e),n=new FormData;n.append("image_file",a,"image.png");const o=await fetch(_e,{method:"POST",headers:{"x-api-key":t},body:n});if(!o.ok){const d=await o.text();throw console.error("Clipdrop error:",d),o.status===401?new Error("Invalid API key"):o.status===402?new Error("Insufficient credits"):o.status===429?new Error("Rate limit exceeded. Please try again later."):new Error(`API error: ${o.status}`)}const i=await o.blob();return new Promise((d,l)=>{const s=new FileReader;s.onload=()=>d(s.result),s.onerror=()=>l(new Error("Failed to read result")),s.readAsDataURL(i)})}async function O(e){return new Promise((t,a)=>{const n=new Image;n.onload=()=>{const o=document.createElement("canvas"),i=o.getContext("2d");if(!i){a(new Error("Failed to get canvas context"));return}o.width=n.width,o.height=n.height,i.filter="sepia(0.3) contrast(1.1) saturate(0.9)",i.drawImage(n,0,0),t(o.toDataURL("image/png"))},n.onerror=()=>a(new Error("Failed to load image")),n.src=e})}function Fe(){const[e,t]=f.useState(!1),[a,n]=f.useState(!1),[o,i]=f.useState(null),[d,l]=f.useState(M()),[s,c]=f.useState(ce()),p=f.useCallback(()=>i(null),[]),m=f.useCallback(v=>{se(v),l(!0),i(null)},[]),b=f.useCallback(v=>{le(v),c(!0),i(null)},[]),y=f.useCallback(async(v,I="vintage")=>{t(!0),i(null);try{return M()?await de({imageDataUrl:v,style:I,strength:.35}):await O(v)}catch(w){const j=w instanceof Error?w.message:"Enhancement failed";if(i(j),j.includes("API")||j.includes("key"))try{return await O(v)}catch{throw w}throw w}finally{t(!1)}},[]),h=f.useCallback(async v=>{n(!0),i(null);try{return await he(v)}catch(I){const w=I instanceof Error?I.message:"Background removal failed";throw i(w),I}finally{n(!1)}},[]);return{enhance:y,removeBg:h,isEnhancing:e,isRemovingBg:a,error:o,hasKey:d,setApiKey:m,hasClipdropKey:s,setClipdropKey:b,clearError:p}}function ue({isOpen:e,onClose:t,onSubmit:a}){const n=g(c=>c.voucherConfig.language),[o,i]=f.useState("");if(!e)return null;const d=c=>{c.preventDefault(),o.trim()&&(a(o.trim()),i(""),t())},s={de:{title:"Stability AI API Key",description:"Um die AI-Bildverbesserung zu nutzen, benötigst du einen Stability AI API Key. Du kannst ihn auf platform.stability.ai erhalten.",placeholder:"sk-...",submit:"Speichern",cancel:"Abbrechen",hint:"Der Key wird lokal in deinem Browser gespeichert."},en:{title:"Stability AI API Key",description:"To use AI image enhancement, you need a Stability AI API key. You can get one at platform.stability.ai.",placeholder:"sk-...",submit:"Save",cancel:"Cancel",hint:"The key is stored locally in your browser."}}[n];return r.jsxs("dialog",{className:"modal modal-open",children:[r.jsxs("div",{className:"modal-box",children:[r.jsx("h3",{className:"font-bold text-lg",children:s.title}),r.jsx("p",{className:"py-4 text-sm opacity-80",children:s.description}),r.jsxs("form",{onSubmit:d,children:[r.jsxs("div",{className:"form-control",children:[r.jsx("input",{type:"password",placeholder:s.placeholder,className:"input input-bordered w-full",value:o,onChange:c=>i(c.target.value),autoFocus:!0}),r.jsx("label",{className:"label",children:r.jsx("span",{className:"label-text-alt",children:s.hint})})]}),r.jsxs("div",{className:"modal-action",children:[r.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t,children:s.cancel}),r.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!o.trim(),children:s.submit})]})]})]}),r.jsx("form",{method:"dialog",className:"modal-backdrop",children:r.jsx("button",{onClick:t,children:"close"})})]})}function $e(){const e=g(u=>u.voucherConfig.language),t=g(u=>u.portrait),a=g(u=>u.setPortrait),n=g(u=>u.setEnhancedPortrait),o=g(u=>u.toggleUseEnhanced),i=g(u=>u.setPortraitZoom),{enhance:d,removeBg:l,isEnhancing:s,isRemovingBg:c,error:p,hasKey:m,setApiKey:b,hasClipdropKey:y}=Fe(),h=T(e),v=f.useRef(null),[I,w]=f.useState(!1),[j,x]=f.useState(!1),C=f.useCallback(async u=>{if(!u.type.startsWith("image/"))return;const k=new FileReader;k.onload=async D=>{var ee;const $=(ee=D.target)==null?void 0:ee.result;if(y)try{const z=await l($);a(z)}catch(z){console.error("Background removal failed, using original:",z),a($)}else a($)},k.readAsDataURL(u)},[a,y,l]),A=f.useCallback(u=>{u.preventDefault(),w(!1);const k=u.dataTransfer.files[0];k&&C(k)},[C]),R=f.useCallback(u=>{u.preventDefault(),w(!0)},[]),K=f.useCallback(u=>{u.preventDefault(),w(!1)},[]),F=()=>{var u;(u=v.current)==null||u.click()},Ie=u=>{var D;const k=(D=u.target.files)==null?void 0:D[0];k&&C(k)},ke=async()=>{if(t.original){if(!m){x(!0);return}try{const u=await d(t.original,"vintage");n(u)}catch(u){console.error("Enhancement failed:",u)}}},Pe=async u=>{if(b(u),t.original)try{const k=await d(t.original,"vintage");n(k)}catch(k){console.error("Enhancement failed:",k)}},je=()=>{a(null)},Ce=t.useEnhanced&&t.enhanced?t.enhanced:t.original;return r.jsxs("div",{className:"space-y-4",children:[t.original?r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex justify-center",children:r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"w-32 h-32 rounded-full overflow-hidden border-4 border-currency-gold shadow-lg",children:r.jsx("img",{src:Ce||"",alt:"Portrait",className:"w-full h-full object-cover",style:{transform:`scale(${t.zoom})`}})}),r.jsx("button",{className:"btn btn-circle btn-xs btn-error absolute -top-1 -right-1",onClick:je,children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),r.jsxs("div",{className:"form-control",children:[r.jsxs("label",{className:"label",children:[r.jsx("span",{className:"label-text",children:h.form.portrait.zoom}),r.jsxs("span",{className:"label-text-alt",children:[Math.round(t.zoom*100),"%"]})]}),r.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:t.zoom,onChange:u=>i(parseFloat(u.target.value)),className:"range range-primary range-sm"})]}),m&&r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("button",{className:`btn btn-secondary ${s?"loading":""}`,onClick:ke,disabled:s,children:s?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"loading loading-spinner loading-sm"}),h.form.portrait.enhancing]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),h.form.portrait.enhance]})}),p&&r.jsxs("div",{className:"alert alert-warning text-sm py-2",children:[r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stroke-current shrink-0 h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),r.jsx("span",{children:p})]}),t.enhanced&&r.jsx("div",{className:"form-control",children:r.jsxs("label",{className:"label cursor-pointer justify-start gap-3",children:[r.jsx("input",{type:"checkbox",className:"toggle toggle-primary",checked:t.useEnhanced,onChange:o}),r.jsx("span",{className:"label-text",children:t.useEnhanced?h.form.portrait.useEnhanced:h.form.portrait.useOriginal})]})})]})]}):r.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${c?"border-primary bg-primary/10 pointer-events-none":I?"border-primary bg-primary/10":"border-base-300 hover:border-primary hover:bg-base-200"}`,onDrop:A,onDragOver:R,onDragLeave:K,onClick:F,children:[r.jsx("input",{ref:v,type:"file",accept:"image/*",className:"hidden",onChange:Ie}),c?r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx("span",{className:"loading loading-spinner loading-lg text-primary"}),r.jsx("p",{className:"font-medium",children:e==="de"?"Hintergrund wird entfernt...":"Removing background..."})]}):r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-12 w-12 text-base-content/50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),r.jsx("p",{className:"font-medium",children:h.form.portrait.upload}),r.jsx("p",{className:"text-sm text-base-content/60",children:h.form.portrait.dragDrop})]})]}),r.jsx(ue,{isOpen:j,onClose:()=>x(!1),onSubmit:Pe})]})}function ze(){return null}const P=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:E&&E.tagName.toUpperCase()==="SCRIPT"&&E.src||new URL("index.cjs",document.baseURI).href}<"u"&&"/"||"/",pe={en:{1:{front:`${P}templates/front_ldpi_en.png`,back:`${P}templates/back_ldpi_en.png`,width:1536,height:1024},5:{front:`${P}templates/front_ldpi_en.png`,back:`${P}templates/back_ldpi_en.png`,width:1536,height:1024},10:{front:`${P}templates/front_ldpi_en.png`,back:`${P}templates/back_ldpi_en.png`,width:1536,height:1024}},de:{1:{front:`${P}templates/front_hdpi_de.webp`,back:`${P}templates/back_hdpi_de.webp`,width:6144,height:3200},5:{front:`${P}templates/front_hdpi_de.webp`,back:`${P}templates/back_hdpi_de.webp`,width:6144,height:3200},10:{front:`${P}templates/front_hdpi_de.webp`,back:`${P}templates/back_hdpi_de.webp`,width:6144,height:3200}}},S={front:{portrait:{x:768,y:490,radiusX:236,radiusY:258},namePlate:{x:768,y:848,fontSize:36,maxWidth:380,align:"center"}},back:{portrait:{x:0,y:0,radiusX:0,radiusY:0},namePlate:{x:768,y:832,fontSize:36,maxWidth:380,align:"center"},contactInfo:{x:380,y:500,fontSize:38,lineHeight:55,align:"center"},description:{x:1150,y:500,fontSize:38,maxWidth:480,lineHeight:42,align:"center"}}},N={front:{portrait:{x:3074,y:1530,radiusX:942,radiusY:1020},namePlate:{x:3072,y:2950,fontSize:144,maxWidth:1520,align:"center"}},back:{portrait:{x:0,y:0,radiusX:0,radiusY:0},namePlate:{x:3072,y:2930,fontSize:144,maxWidth:1520,align:"center"},contactInfo:{x:1520,y:1680,fontSize:160,lineHeight:280,align:"center"},description:{x:4600,y:1680,fontSize:145,maxWidth:2e3,lineHeight:210,align:"center"}}};function V(e){return e==="de"?N:S}function G(e,t){return pe[e][t]}const H=new Map;async function _(e){return H.has(e)?H.get(e):new Promise((t,a)=>{const n=new Image;n.crossOrigin="anonymous",n.onload=()=>{H.set(e,n),t(n)},n.onerror=a,n.src=e})}function Z(e,t,a,n){e.drawImage(t,0,0,a,n)}function me(e,t,a,n,o,i,d=1){e.save(),e.beginPath(),e.ellipse(a,n,o,i,0,0,Math.PI*2),e.closePath(),e.clip();const l=t.width/t.height,s=o/i,c=o*2,p=i*2;let m,b;l>s?(b=p,m=p*l):(m=c,b=c/l),m*=d,b*=d;const y=a-m/2,h=n-b/2;e.drawImage(t,y,h,m,b),e.restore()}function X(e,t,a,n="#2a3a2a"){e.save(),e.font=`${a.fontSize}px "Times New Roman", serif`,e.textAlign=a.align||"center",e.textBaseline="middle",e.fillStyle=n,a.maxWidth?e.fillText(t,a.x,a.y,a.maxWidth):e.fillText(t,a.x,a.y),e.restore()}function ge(e,t,a,n="#2a3a2a"){e.save(),e.font=`${a.fontSize}px "Times New Roman", serif`,e.textAlign=a.align||"center",e.textBaseline="top",e.fillStyle=n;const o=a.maxWidth||400,i=a.lineHeight||a.fontSize*1.4,d=t.split(" "),l=[];let s="";for(const m of d){const b=s?`${s} ${m}`:m;e.measureText(b).width>o&&s?(l.push(s),s=m):s=b}s&&l.push(s);const c=l.length*i;let p=a.y-c/2;for(const m of l)e.fillText(m,a.x,p),p+=i;e.restore()}function fe(e,t,a,n,o,i="#2a3a2a"){e.save(),e.font=`${o.fontSize}px "Times New Roman", serif`,e.textAlign=o.align||"center",e.textBaseline="middle",e.fillStyle=i;const d=o.lineHeight||o.fontSize*1.8,l=[t,a,n].filter(Boolean),s=(l.length-1)*d;let c=o.y-s/2;for(const p of l)p&&(e.fillText(p,o.x,c),c+=d);e.restore()}async function J(e,t,a,n,o,i,d,l=1){const s=e.getContext("2d");if(!s)return;e.width=i,e.height=d,s.clearRect(0,0,i,d);const c=await _(t);if(Z(s,c,i,d),a)try{const p=await _(a);me(s,p,o.portrait.x,o.portrait.y,o.portrait.radiusX,o.portrait.radiusY,l)}catch(p){console.error("Failed to load portrait:",p)}n&&X(s,n,o.namePlate)}async function Q(e,t,a,n,o,i,d,l,s){const c=e.getContext("2d");if(!c)return;e.width=l,e.height=s,c.clearRect(0,0,l,s);const p=await _(t);Z(c,p,l,s),d.contactInfo&&(a||n||o)&&fe(c,a,n,o,d.contactInfo),d.description&&i&&ge(c,i,d.description),a&&X(c,a,d.namePlate)}function He(){const e=g(x=>x.voucherConfig.language),t=g(x=>x.voucherConfig.hours),a=g(x=>x.voucherConfig.description),n=g(x=>x.personalInfo),o=g(x=>x.portrait),i=g(x=>x.currentSide),d=g(x=>x.flipSide),l=T(e),s=f.useRef(null),c=f.useRef(null),p=f.useRef(null),[m,b]=f.useState(!1),y=G(e,t),h=V(e),v=o.useEnhanced&&o.enhanced?o.enhanced:o.original,I=W(e,t,a);f.useEffect(()=>{s.current&&J(s.current,y.front,v,n.name,h.front,y.width,y.height,o.zoom)},[y,v,n.name,h,o.zoom]),f.useEffect(()=>{c.current&&Q(c.current,y.back,n.name,n.email,n.phone,I,h.back,y.width,y.height)},[y,n,I,h]);const w=()=>{b(!0),setTimeout(()=>{d(),b(!1)},150)},j=y.width/y.height;return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{className:"tabs tabs-boxed bg-base-200",children:[r.jsx("button",{className:`tab ${i==="front"?"tab-active bg-primary text-primary-content font-semibold":""}`,onClick:()=>i!=="front"&&w(),children:l.preview.front}),r.jsx("button",{className:`tab ${i==="back"?"tab-active bg-primary text-primary-content font-semibold":""}`,onClick:()=>i!=="back"&&w(),children:l.preview.back})]}),r.jsxs("button",{className:"btn btn-ghost btn-sm",onClick:w,children:[r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),l.preview.flip]})]}),r.jsxs("div",{ref:p,className:"relative w-full overflow-hidden shadow-lg",style:{aspectRatio:j},children:[r.jsx("canvas",{ref:s,className:`absolute inset-0 w-full h-full transition-all duration-300 ${i==="front"?m?"opacity-0 scale-95":"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"}`}),r.jsx("canvas",{ref:c,className:`absolute inset-0 w-full h-full transition-all duration-300 ${i==="back"?m?"opacity-0 scale-95":"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"}`})]})]})}function Me(){const e=f.useRef(null),t=f.useRef(null);return{frontCanvasRef:e,backCanvasRef:t}}async function be(e){const{frontTemplateSrc:t,backTemplateSrc:a,templateWidth:n,templateHeight:o,layout:i,portrait:d,portraitZoom:l=1,name:s,email:c,phone:p,description:m}=e,b=document.createElement("canvas"),y=document.createElement("canvas");await Promise.all([J(b,t,d,s,i.front,n,o,l),Q(y,a,s,c,p,m,i.back,n,o)]);const h=new Ne({orientation:"landscape",unit:"mm",format:"a4"}),v=297,I=210,w=10,j=n/o;let x=v-w*2,C=x/j;C>I-w*2&&(C=I-w*2,x=C*j);const A=(v-x)/2,R=(I-C)/2,K=b.toDataURL("image/jpeg",.95);h.addImage(K,"JPEG",A,R,x,C),h.addPage();const F=y.toDataURL("image/jpeg",.95);return h.addImage(F,"JPEG",A,R,x,C),h.output("blob")}function ye(e,t){const a=URL.createObjectURL(e),n=document.createElement("a");n.href=a,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(a)}async function xe(e){const t=await be(e);ye(t,e.filename)}function Oe(){const e=g(h=>h.voucherConfig.language),t=g(h=>h.voucherConfig.hours),a=g(h=>h.voucherConfig.description),n=g(h=>h.personalInfo),o=g(h=>h.portrait),i=g(h=>h.isExporting),d=g(h=>h.setIsExporting),l=T(e),s=G(e,t),c=V(e),p=o.useEnhanced&&o.enhanced?o.enhanced:o.original,m=W(e,t,a),b=n.name.trim().length>0&&n.email.trim().length>0&&n.phone.trim().length>0&&o.original!==null,y=async()=>{if(!(!b||i)){d(!0);try{const h=`zeitgutschein-${t}h-${n.name.replace(/\s+/g,"-").toLowerCase()}.pdf`;await xe({frontTemplateSrc:s.front,backTemplateSrc:s.back,templateWidth:s.width,templateHeight:s.height,layout:c,portrait:p,portraitZoom:o.zoom,name:n.name,email:n.email,phone:n.phone,description:m,filename:h})}catch(h){console.error("PDF export failed:",h)}finally{d(!1)}}};return r.jsx("button",{className:`btn btn-primary flex-1 ${i?"loading":""}`,onClick:y,disabled:!b||i,children:i?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"loading loading-spinner loading-sm"}),l.export.exporting]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),l.export.button]})})}function we(){const e=g(n=>n.voucherConfig.language),t=g(n=>n.setLanguage),a=n=>{t(n)};return r.jsxs("div",{className:"join",children:[r.jsx("button",{className:`join-item btn btn-sm ${e==="de"?"btn-active btn-primary":"btn-ghost"}`,onClick:()=>a("de"),children:"DE"}),r.jsx("button",{className:`join-item btn btn-sm ${e==="en"?"btn-active btn-primary":"btn-ghost"}`,onClick:()=>a("en"),children:"EN"})]})}function We(){const e=g(a=>a.voucherConfig.language),t=T(e);return r.jsxs("div",{className:"navbar bg-currency-green text-currency-cream shadow-lg",children:[r.jsx("div",{className:"navbar-start",children:r.jsx("a",{className:"btn btn-ghost text-xl font-currency font-bold",children:t.header.title})}),r.jsx("div",{className:"navbar-center hidden sm:flex",children:r.jsx("span",{className:"text-sm opacity-80",children:t.header.subtitle})}),r.jsx("div",{className:"navbar-end",children:r.jsx(we,{})})]})}const B="/",Ye={id:"time-voucher-classic-de",name:"Zeitgutschein Classic",type:"time-voucher",category:"classic",images:{front:`${B}templates/front_hdpi_de.jpg`,back:`${B}templates/back_hdpi_de.jpg`,width:6144,height:4096},fields:[{id:"name",type:"text",label:{de:"Name",en:"Name"},required:!0,validation:{minLength:1,maxLength:50}},{id:"hours",type:"select",label:{de:"Stunden",en:"Hours"},required:!0,options:["1","5","10"]},{id:"portrait",type:"image",label:{de:"Portrait",en:"Portrait"},required:!1},{id:"email",type:"text",label:{de:"E-Mail",en:"Email"},required:!1},{id:"phone",type:"text",label:{de:"Telefon",en:"Phone"},required:!1},{id:"description",type:"textarea",label:{de:"Beschreibung",en:"Description"},required:!1,validation:{maxLength:200}}],layout:{front:{portrait:N.front.portrait,name:N.front.namePlate},back:{name:N.back.namePlate,contactInfo:N.back.contactInfo,description:N.back.description}},languages:["de"]},qe={id:"time-voucher-classic-en",name:"Time Voucher Classic",type:"time-voucher",category:"classic",images:{front:`${B}templates/front_ldpi_en.png`,back:`${B}templates/back_ldpi_en.png`,width:1536,height:1024},fields:[{id:"name",type:"text",label:{de:"Name",en:"Name"},required:!0,validation:{minLength:1,maxLength:50}},{id:"hours",type:"select",label:{de:"Stunden",en:"Hours"},required:!0,options:["1","5","10"]},{id:"portrait",type:"image",label:{de:"Portrait",en:"Portrait"},required:!1},{id:"email",type:"text",label:{de:"E-Mail",en:"Email"},required:!1},{id:"phone",type:"text",label:{de:"Telefon",en:"Phone"},required:!1},{id:"description",type:"textarea",label:{de:"Beschreibung",en:"Description"},required:!1,validation:{maxLength:200}}],layout:{front:{portrait:S.front.portrait,name:S.front.namePlate},back:{name:S.back.namePlate,contactInfo:S.back.contactInfo,description:S.back.description}},languages:["en"]},ae=[Ye,qe],ve={async listTemplates(e){let t=[...ae];return e!=null&&e.type&&(t=t.filter(a=>a.type===e.type)),e!=null&&e.category&&(t=t.filter(a=>a.category===e.category)),e!=null&&e.language&&(t=t.filter(a=>a.languages.includes(e.language))),t},async getTemplate(e){const t=ae.find(a=>a.id===e);if(!t)throw new Error(`Template not found: ${e}`);return t}};function Ve(e){return e==="de"?"time-voucher-classic-de":"time-voucher-classic-en"}let U=ve;function Ge(e){U=e}function Ze(){return U}async function Xe(e){return U.listTemplates(e)}async function Je(e){return U.getTemplate(e)}exports.ApiKeyModal=ue;exports.BillPreview=He;exports.ExportButton=Oe;exports.Header=We;exports.LAYOUT_HDPI=N;exports.LAYOUT_LDPI=S;exports.LanguageToggle=we;exports.PersonalInfoForm=Re;exports.PortraitUpload=$e;exports.TEMPLATES=pe;exports.VoucherConfig=ze;exports.downloadBlob=ye;exports.drawContactInfo=fe;exports.drawMultilineText=ge;exports.drawOvalPortrait=me;exports.drawTemplate=Z;exports.drawText=X;exports.enhancePortrait=de;exports.enhancePortraitFallback=O;exports.exportBillAsPDF=xe;exports.formatDescription=W;exports.generateBillPDF=be;exports.getApiKey=Y;exports.getClipdropApiKey=q;exports.getDefaultTemplateId=Ve;exports.getLayout=V;exports.getTemplate=G;exports.getTemplateById=Je;exports.getTemplateProvider=Ze;exports.hasApiKey=M;exports.hasClipdropApiKey=ce;exports.listTemplates=Xe;exports.loadImage=_;exports.removeBackground=he;exports.renderBackSide=Q;exports.renderFrontSide=J;exports.setApiKey=se;exports.setClipdropApiKey=le;exports.setTemplateProvider=Ge;exports.staticTemplateProvider=ve;exports.t=T;exports.useBillCanvasRefs=Me;exports.useBillStore=g;
|
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,8 @@ export declare function generateBillPDF(options: PDFGeneratorOptions): Promise<B
|
|
|
94
94
|
|
|
95
95
|
export declare function getApiKey(): string | null;
|
|
96
96
|
|
|
97
|
+
export declare function getClipdropApiKey(): string | null;
|
|
98
|
+
|
|
97
99
|
/**
|
|
98
100
|
* Get the default template for a given language
|
|
99
101
|
*/
|
|
@@ -118,6 +120,8 @@ export declare function getTemplateProvider(): TemplateProvider;
|
|
|
118
120
|
|
|
119
121
|
export declare function hasApiKey(): boolean;
|
|
120
122
|
|
|
123
|
+
export declare function hasClipdropApiKey(): boolean;
|
|
124
|
+
|
|
121
125
|
export declare function Header(): JSX.Element;
|
|
122
126
|
|
|
123
127
|
export declare type HourValue = 1 | 5 | 10;
|
|
@@ -187,12 +191,16 @@ export declare interface PortraitState {
|
|
|
187
191
|
|
|
188
192
|
export declare function PortraitUpload(): JSX.Element;
|
|
189
193
|
|
|
194
|
+
export declare function removeBackground(imageDataUrl: string): Promise<string>;
|
|
195
|
+
|
|
190
196
|
export declare function renderBackSide(canvas: HTMLCanvasElement, templateSrc: string, name: string, email: string, phone: string, description: string, layout: TemplateLayout, width: number, height: number): Promise<void>;
|
|
191
197
|
|
|
192
198
|
export declare function renderFrontSide(canvas: HTMLCanvasElement, templateSrc: string, portraitSrc: string | null, name: string, layout: TemplateLayout, width: number, height: number, portraitZoom?: number): Promise<void>;
|
|
193
199
|
|
|
194
200
|
export declare function setApiKey(key: string): void;
|
|
195
201
|
|
|
202
|
+
export declare function setClipdropApiKey(key: string): void;
|
|
203
|
+
|
|
196
204
|
/**
|
|
197
205
|
* Set a custom template provider
|
|
198
206
|
* Use this to switch to a CMS-based provider or other source
|