@dintero/discounts-web-sdk 0.3.0 → 0.3.2

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.
@@ -1,5 +1,8 @@
1
1
  name: CI
2
2
 
3
+ permissions:
4
+ contents: read
5
+
3
6
  on:
4
7
  pull_request:
5
8
  branches: [master]
@@ -0,0 +1,101 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL Advanced"
13
+
14
+ on:
15
+ push:
16
+ branches: ["master"]
17
+ pull_request:
18
+ branches: ["master"]
19
+ schedule:
20
+ - cron: "28 18 * * 3"
21
+
22
+ jobs:
23
+ analyze:
24
+ name: Analyze (${{ matrix.language }})
25
+ # Runner size impacts CodeQL analysis time. To learn more, please see:
26
+ # - https://gh.io/recommended-hardware-resources-for-running-codeql
27
+ # - https://gh.io/supported-runners-and-hardware-resources
28
+ # - https://gh.io/using-larger-runners (GitHub.com only)
29
+ # Consider using larger runners or machines with greater resources for possible analysis time improvements.
30
+ runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31
+ permissions:
32
+ # required for all workflows
33
+ security-events: write
34
+
35
+ # required to fetch internal or private CodeQL packs
36
+ packages: read
37
+
38
+ # only required for workflows in private repositories
39
+ actions: read
40
+ contents: read
41
+
42
+ strategy:
43
+ fail-fast: false
44
+ matrix:
45
+ include:
46
+ - language: actions
47
+ build-mode: none
48
+ - language: javascript-typescript
49
+ build-mode: none
50
+ # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
51
+ # Use `c-cpp` to analyze code written in C, C++ or both
52
+ # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
53
+ # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
54
+ # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
55
+ # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
56
+ # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
57
+ # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
58
+ steps:
59
+ - name: Checkout repository
60
+ uses: actions/checkout@v4
61
+
62
+ # Add any setup steps before running the `github/codeql-action/init` action.
63
+ # This includes steps like installing compilers or runtimes (`actions/setup-node`
64
+ # or others). This is typically only required for manual builds.
65
+ # - name: Setup runtime (example)
66
+ # uses: actions/setup-example@v1
67
+
68
+ # Initializes the CodeQL tools for scanning.
69
+ - name: Initialize CodeQL
70
+ uses: github/codeql-action/init@v4
71
+ with:
72
+ languages: ${{ matrix.language }}
73
+ build-mode: ${{ matrix.build-mode }}
74
+ # If you wish to specify custom queries, you can do so here or in a config file.
75
+ # By default, queries listed here will override any specified in a config file.
76
+ # Prefix the list here with "+" to use these queries and those in the config file.
77
+
78
+ # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
79
+ # queries: security-extended,security-and-quality
80
+
81
+ # If the analyze step fails for one of the languages you are analyzing with
82
+ # "We were unable to automatically build your code", modify the matrix above
83
+ # to set the build mode to "manual" for that language. Then modify this step
84
+ # to build your code.
85
+ # ℹ️ Command-line programs to run using the OS shell.
86
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
87
+ - name: Run manual build steps
88
+ if: matrix.build-mode == 'manual'
89
+ shell: bash
90
+ run: |
91
+ echo 'If you are using a "manual" build mode for one or more of the' \
92
+ 'languages you are analyzing, replace this with the commands to build' \
93
+ 'your code, for example:'
94
+ echo ' make bootstrap'
95
+ echo ' make release'
96
+ exit 1
97
+
98
+ - name: Perform CodeQL Analysis
99
+ uses: github/codeql-action/analyze@v4
100
+ with:
101
+ category: "/language:${{matrix.language}}"
@@ -568,7 +568,7 @@ const createLoading = configuration => {
568
568
 
569
569
  var pkg = {
570
570
  name: "@dintero/discounts-web-sdk",
571
- version: "0.3.0",
571
+ version: "0.3.2",
572
572
  description: "Dintero Discounts SDK for web frontends",
573
573
  main: "dist/dintero-discounts-web-sdk.cjs.js",
574
574
  module: "dist/dintero-discounts-web-sdk.esm.js",
@@ -598,15 +598,15 @@ var pkg = {
598
598
  url: "https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues"
599
599
  },
600
600
  devDependencies: {
601
- "@babel/core": "7.28.4",
602
- "@babel/preset-typescript": "7.27.1",
601
+ "@babel/core": "7.28.6",
602
+ "@babel/preset-typescript": "7.28.5",
603
603
  "@preconstruct/cli": "2.8.12",
604
604
  "@semantic-release/git": "10.0.1",
605
- "happy-dom": "20.0.8",
606
- prettier: "3.6.2",
607
- "semantic-release": "25.0.1",
605
+ "happy-dom": "20.3.3",
606
+ prettier: "3.8.0",
607
+ "semantic-release": "25.0.2",
608
608
  typescript: "5.9.3",
609
- vitest: "4.0.1"
609
+ vitest: "4.0.17"
610
610
  }
611
611
  };
612
612
 
@@ -568,7 +568,7 @@ const createLoading = configuration => {
568
568
 
569
569
  var pkg = {
570
570
  name: "@dintero/discounts-web-sdk",
571
- version: "0.3.0",
571
+ version: "0.3.2",
572
572
  description: "Dintero Discounts SDK for web frontends",
573
573
  main: "dist/dintero-discounts-web-sdk.cjs.js",
574
574
  module: "dist/dintero-discounts-web-sdk.esm.js",
@@ -598,15 +598,15 @@ var pkg = {
598
598
  url: "https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues"
599
599
  },
600
600
  devDependencies: {
601
- "@babel/core": "7.28.4",
602
- "@babel/preset-typescript": "7.27.1",
601
+ "@babel/core": "7.28.6",
602
+ "@babel/preset-typescript": "7.28.5",
603
603
  "@preconstruct/cli": "2.8.12",
604
604
  "@semantic-release/git": "10.0.1",
605
- "happy-dom": "20.0.8",
606
- prettier: "3.6.2",
607
- "semantic-release": "25.0.1",
605
+ "happy-dom": "20.3.3",
606
+ prettier: "3.8.0",
607
+ "semantic-release": "25.0.2",
608
608
  typescript: "5.9.3",
609
- vitest: "4.0.1"
609
+ vitest: "4.0.17"
610
610
  }
611
611
  };
612
612
 
@@ -564,7 +564,7 @@ const createLoading = configuration => {
564
564
 
565
565
  var pkg = {
566
566
  name: "@dintero/discounts-web-sdk",
567
- version: "0.3.0",
567
+ version: "0.3.2",
568
568
  description: "Dintero Discounts SDK for web frontends",
569
569
  main: "dist/dintero-discounts-web-sdk.cjs.js",
570
570
  module: "dist/dintero-discounts-web-sdk.esm.js",
@@ -594,15 +594,15 @@ var pkg = {
594
594
  url: "https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues"
595
595
  },
596
596
  devDependencies: {
597
- "@babel/core": "7.28.4",
598
- "@babel/preset-typescript": "7.27.1",
597
+ "@babel/core": "7.28.6",
598
+ "@babel/preset-typescript": "7.28.5",
599
599
  "@preconstruct/cli": "2.8.12",
600
600
  "@semantic-release/git": "10.0.1",
601
- "happy-dom": "20.0.8",
602
- prettier: "3.6.2",
603
- "semantic-release": "25.0.1",
601
+ "happy-dom": "20.3.3",
602
+ prettier: "3.8.0",
603
+ "semantic-release": "25.0.2",
604
604
  typescript: "5.9.3",
605
- vitest: "4.0.1"
605
+ vitest: "4.0.17"
606
606
  }
607
607
  };
608
608
 
@@ -1,2 +1,2 @@
1
- !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).discounts={})}(this,(function(n){"use strict";const e=n=>{const e=document.createElement(n.tag);return n.attributes&&r(e,n.attributes),n.handlers&&i(e,n.handlers),n.styles&&t(e,n.styles,n.theme),n.innerHTML&&(e.innerHTML=n.innerHTML),e},t=(n,e,t)=>{e.forEach((e=>{const r="dintero-deals-"+(n=>{let e=0;for(var t=0;t<n.length;t++)e=(e<<5)-e+n.charCodeAt(t),e|=0;return e.toString(36)})(e("dintero-deals",t));((n,e)=>{n.className.split(" ").includes(e)||(n.className=n.className+" "+e)})(n,r);if(!document.querySelector(`[data-css-hash=${r}]`)){const n=document.createElement("style");n.innerHTML=e(r,t),n.setAttribute("data-css-hash",r),document.head.appendChild(n)}}))},r=(n,e)=>{Object.keys(e).forEach((t=>{n.setAttribute(t,e[t])}))},i=(n,e)=>{Object.keys(e).forEach((t=>{n.addEventListener(t,e[t])}))},a={no:{rewards:{discount_item_quantity:{three_for_two:"3 for 2",generic:"Kjøp {{require}} betal for {{payFor}}"},discount_amount:"{{monetaryAmount}} rabatt"},limitations:{discount_reward_usage:"Antall: <strong>{{discount_reward_usage}}</strong>",discount_repeat_usage:"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>"},requirements:{purchase_from:"Tilbudet starter <strong>{{purchase_from}}</strong>",purchase_to:"Tilbudet utgår <strong>{{purchase_to}}</strong>"},errors:{fetch:"⚠️ <br/>En feil oppstod under lasting av tilbud..."}}},o=/(\{\{)[^}]*(\}\})/g,s=(n,e)=>{const t=n.match(o)||[],r=e||{};return t.reduce(((n,e)=>{const t=e.replace("{{","").replace("}}",""),i=r[t]||"";return n.replace(e,i)}),n)},d=(n,e,t)=>{const r=t||{},i=n.toString(),a=i.length-e.currency.exponent,o=i.slice(0,a)||"0",s=i.slice(a),d="00"!=s||r.decimal?o+"."+s:o;return"short"===r.variant&&"00"===s?o+",-":r.currency?"prefix"===e.currency.position?e.currency.value+" "+d:d+" "+e.currency.value:d},c=n=>n<10?`0${n}`:n.toString(),u=(n,e)=>{try{const t=new Date(n);if("no"===e.language){const n=c(t.getDate()),e=c(t.getMonth()+1);return[n,e,t.getFullYear()].join(".")}return(new Intl.DateTimeFormat).format(t)}catch(e){return n.substr(0,10)}},p=n=>`\n.${n} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`,l=n=>n.links&&n.links.find((n=>n.rel&&"webshop"===n.rel)),m=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${e.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${n} {\n width: 100%;\n max-width: 100%;\n } \n }\n`,h=n=>`\n.${n} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`,g=n=>`\n.${n} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`,f=(n,e)=>`\n.${n} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${e.borderRadius} ${e.borderRadius} 0;\n padding: 5px 0;\n background: ${e?.secondary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${e.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,b=(n,e)=>`\n.${n} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${e.borderRadius} 0 0 ${e.borderRadius};\n padding: 5px 0;\n background: ${e?.primary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${e.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,y=n=>`\n.${n} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`,x=n=>`\n.${n} {\n margin-top: 0;\n}`,w=n=>`\n.${n} {\n font-size: 0.75em;\n}\n.${n} > span{\n display: block;\n}\n`,_=(n,t)=>{const r=((n,e)=>{const t=a[e.language];if("discount_item_new_price"===n.reward.type)return d(n.reward.value,e,{variant:"short"});if("discount_percent"===n.reward.type)return n.reward.value+"%";if("discount_item_quantity"===n.reward.type){if(3===n.requirement.item.quantity&&1===n.reward.value)return t.rewards.discount_item_quantity.three_for_two;{const e=n.requirement.item.quantity,r=n.requirement.item.quantity-n.reward.value;return s(t.rewards.discount_item_quantity.generic,{require:e,payFor:r})}}if("discount_amount"===n.reward.type){const r=d(n.reward.value,e,{decimal:!1});return s(t.rewards.discount_amount,{monetaryAmount:r})}return"discount_item_percent"===n.reward.type?n.reward.value+"%":""})(n,t);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[b]})},$=(n,t)=>{const r=e({tag:l(n)?"a":"div",styles:[p,m],theme:t.theme}),i=((n,t)=>{const r=(n=>n&&n.metadata&&n.metadata.label||void 0)(n);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[f]})})(n,t),o=_(n,t),d=(n=>{const t=e({tag:"div",styles:[p,h]}),r=n.links.find((n=>["medium_discount_image","thumbnail_discount_image".includes(n.rel)])),i=r&&e({tag:"img",attributes:{src:r.href,alt:n.name,loading:"lazy"},styles:[p,g]});return i&&t.appendChild(i),t})(n),c=n?.name&&e({tag:"h4",innerHTML:n.name,styles:[y]}),b=n?.metadata?.subtitle&&e({tag:"p",innerHTML:n.metadata.subtitle,styles:[x]}),$=n.description&&e({tag:"p",innerHTML:n.description}),v=((n,t)=>{const r=a[t.language],i=e({tag:"small",styles:[p,w]});return[n.limitation.discount_reward_usage&&-1!==n.limitation.discount_reward_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_reward_usage,{discount_reward_usage:n.limitation.discount_reward_usage})}),n.limitation.discount_repeat_usage&&-1!==n.limitation.discount_repeat_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_repeat_usage,{discount_repeat_usage:n.limitation.discount_repeat_usage})}),new Date(n.requirement.purchase_from||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_from,{purchase_from:u(n.requirement.purchase_from,t)})}),new Date(n.requirement.purchase_to||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_to,{purchase_to:u(n.requirement.purchase_to,t)})})].filter((n=>n)).forEach((n=>i.appendChild(n))),i})(n,t);return[i,o,d,c,b,$,v].filter((n=>n)).forEach((n=>r.appendChild(n))),r},v=(n,e)=>{const t=new Headers;return Object.entries({...n,"Dintero-System-Name":"deals-web-sdk","Dintero-System-Version":e.version}).forEach((([n,e])=>{t.append(n,e)})),t},k=n=>(n=>{if(!n.api)throw new Error("Authentication configuration missing");const e=window.btoa(`${n.api.key}:${n.api.secret}`),t=v({Authorization:`Basic ${e}`,"content-type":"application/json"},n),r=JSON.stringify({grant_type:"client_credentials",audience:`${n.api.url}/v1/accounts/${n.api.account}`});return window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/auth/token`,{method:"POST",headers:t,body:r}).then((n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")}))})(n).then((e=>{const t=v({Authorization:`${e.token_type} ${e.access_token}`},n);return n.api.discountId?window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules/${n.api.discountId}`,{headers:t}).then((n=>{if(200===n.status)return n.json().then((n=>[n]));throw new Error("Authentication failed")})):window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules?limit=${n.api.limit}`,{headers:t}).then((n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")}))})),T=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`,q=(n,e)=>`\n.${n} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${n}:after {\n content: " ";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;const M={language:"no",version:"0.3.0",linkTarget:"_self",currency:{value:"Kr",position:"suffix",exponent:2},theme:{background:"#fff",primary:"#333",secondary:"#333",color:"inherit",borderRadius:"2px",fontSize:"inherit"},api:{account:"",key:"",secret:"",url:"https://api.dintero.com",limit:50}},z=(n,e)=>`\n.${n} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${e.fontSize};\n color: ${e.color};\n}`,E=(n,t)=>{const r=e({tag:"div",styles:[p,z],theme:n.theme});return t.forEach((e=>{const t=$(e,n),i=l(e);i&&(t.setAttribute("target",n?.linkTarget||"_self"),t.setAttribute("href",i.href)),r.appendChild(t)})),n.container.appendChild(r),{destroy:()=>{n.container.removeChild(r)}}};n.embed=async n=>{const t=(r=M,i=n,{...r,...i,currency:{...r.currency,...i.currency},theme:{...r.theme,...i.theme},api:{...r.api,...i.api}});var r,i;if(!t.container||!t.container.appendChild)throw console.error("Invalid configuration"),new Error("Invalid configuration");if(t.discounts)return E(t,t.discounts);{const r=(n=>e({tag:"div",styles:[p,q],theme:n.theme}))(t);try{n.container.appendChild(r);const e=await k(t);return t.container.removeChild(r),E(t,e)}catch(i){n.container.removeChild(r);const o=(n=>{const t=a[n.language];return e({tag:"div",styles:[p,T],theme:n.theme,innerHTML:t.errors.fetch})})(t);return t.container.appendChild(o),{destroy:()=>{n.container.removeChild(o)}}}}},Object.defineProperty(n,"__esModule",{value:!0})}));
1
+ !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).discounts={})}(this,function(n){"use strict";const e=n=>{const e=document.createElement(n.tag);return n.attributes&&r(e,n.attributes),n.handlers&&i(e,n.handlers),n.styles&&t(e,n.styles,n.theme),n.innerHTML&&(e.innerHTML=n.innerHTML),e},t=(n,e,t)=>{e.forEach(e=>{const r="dintero-deals-"+(n=>{let e=0;for(var t=0;t<n.length;t++)e=(e<<5)-e+n.charCodeAt(t),e&=e;return e.toString(36)})(e("dintero-deals",t));((n,e)=>{n.className.split(" ").includes(e)||(n.className=n.className+" "+e)})(n,r);if(!document.querySelector(`[data-css-hash=${r}]`)){const n=document.createElement("style");n.innerHTML=e(r,t),n.setAttribute("data-css-hash",r),document.head.appendChild(n)}})},r=(n,e)=>{Object.keys(e).forEach(t=>{n.setAttribute(t,e[t])})},i=(n,e)=>{Object.keys(e).forEach(t=>{n.addEventListener(t,e[t])})},a={no:{rewards:{discount_item_quantity:{three_for_two:"3 for 2",generic:"Kjøp {{require}} betal for {{payFor}}"},discount_amount:"{{monetaryAmount}} rabatt"},limitations:{discount_reward_usage:"Antall: <strong>{{discount_reward_usage}}</strong>",discount_repeat_usage:"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>"},requirements:{purchase_from:"Tilbudet starter <strong>{{purchase_from}}</strong>",purchase_to:"Tilbudet utgår <strong>{{purchase_to}}</strong>"},errors:{fetch:"⚠️ <br/>En feil oppstod under lasting av tilbud..."}}},o=/(\{\{)[^}]*(\}\})/g,s=(n,e)=>{const t=n.match(o)||[],r=e||{};return t.reduce((n,e)=>{const t=e.replace("{{","").replace("}}",""),i=r[t]||"";return n.replace(e,i)},n)},d=(n,e,t)=>{const r=t||{},i=n.toString(),a=i.length-e.currency.exponent,o=i.slice(0,a)||"0",s=i.slice(a),d="00"!=s||r.decimal?o+"."+s:o;return"short"===r.variant&&"00"===s?o+",-":r.currency?"prefix"===e.currency.position?e.currency.value+" "+d:d+" "+e.currency.value:d},c=n=>n<10?`0${n}`:n.toString(),u=(n,e)=>{try{const t=new Date(n);if("no"===e.language){const n=c(t.getDate()),e=c(t.getMonth()+1);return[n,e,t.getFullYear()].join(".")}return(new Intl.DateTimeFormat).format(t)}catch(e){return n.substr(0,10)}},p=n=>`\n.${n} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`,l=n=>n.links&&n.links.find(n=>n.rel&&"webshop"===n.rel),m=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${e.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${n} {\n width: 100%;\n max-width: 100%;\n } \n }\n`,h=n=>`\n.${n} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`,g=n=>`\n.${n} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`,f=(n,e)=>`\n.${n} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${e.borderRadius} ${e.borderRadius} 0;\n padding: 5px 0;\n background: ${e?.secondary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${e.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,b=(n,e)=>`\n.${n} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${e.borderRadius} 0 0 ${e.borderRadius};\n padding: 5px 0;\n background: ${e?.primary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${e.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,y=n=>`\n.${n} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`,x=n=>`\n.${n} {\n margin-top: 0;\n}`,w=n=>`\n.${n} {\n font-size: 0.75em;\n}\n.${n} > span{\n display: block;\n}\n`,_=(n,t)=>{const r=((n,e)=>{const t=a[e.language];if("discount_item_new_price"===n.reward.type)return d(n.reward.value,e,{variant:"short"});if("discount_percent"===n.reward.type)return n.reward.value+"%";if("discount_item_quantity"===n.reward.type){if(3===n.requirement.item.quantity&&1===n.reward.value)return t.rewards.discount_item_quantity.three_for_two;{const e=n.requirement.item.quantity,r=n.requirement.item.quantity-n.reward.value;return s(t.rewards.discount_item_quantity.generic,{require:e,payFor:r})}}if("discount_amount"===n.reward.type){const r=d(n.reward.value,e,{decimal:!1});return s(t.rewards.discount_amount,{monetaryAmount:r})}return"discount_item_percent"===n.reward.type?n.reward.value+"%":""})(n,t);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[b]})},$=(n,t)=>{const r=e({tag:l(n)?"a":"div",styles:[p,m],theme:t.theme}),i=((n,t)=>{const r=(n=>n&&n.metadata&&n.metadata.label||void 0)(n);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[f]})})(n,t),o=_(n,t),d=(n=>{const t=e({tag:"div",styles:[p,h]}),r=n.links.find(n=>["medium_discount_image","thumbnail_discount_image".includes(n.rel)]),i=r&&e({tag:"img",attributes:{src:r.href,alt:n.name,loading:"lazy"},styles:[p,g]});return i&&t.appendChild(i),t})(n),c=n?.name&&e({tag:"h4",innerHTML:n.name,styles:[y]}),b=n?.metadata?.subtitle&&e({tag:"p",innerHTML:n.metadata.subtitle,styles:[x]}),$=n.description&&e({tag:"p",innerHTML:n.description}),v=((n,t)=>{const r=a[t.language],i=e({tag:"small",styles:[p,w]});return[n.limitation.discount_reward_usage&&-1!==n.limitation.discount_reward_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_reward_usage,{discount_reward_usage:n.limitation.discount_reward_usage})}),n.limitation.discount_repeat_usage&&-1!==n.limitation.discount_repeat_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_repeat_usage,{discount_repeat_usage:n.limitation.discount_repeat_usage})}),new Date(n.requirement.purchase_from||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_from,{purchase_from:u(n.requirement.purchase_from,t)})}),new Date(n.requirement.purchase_to||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_to,{purchase_to:u(n.requirement.purchase_to,t)})})].filter(n=>n).forEach(n=>i.appendChild(n)),i})(n,t);return[i,o,d,c,b,$,v].filter(n=>n).forEach(n=>r.appendChild(n)),r},v=(n,e)=>{const t=new Headers;return Object.entries({...n,"Dintero-System-Name":"deals-web-sdk","Dintero-System-Version":e.version}).forEach(([n,e])=>{t.append(n,e)}),t},k=n=>(n=>{if(!n.api)throw new Error("Authentication configuration missing");const e=window.btoa(`${n.api.key}:${n.api.secret}`),t=v({Authorization:`Basic ${e}`,"content-type":"application/json"},n),r=JSON.stringify({grant_type:"client_credentials",audience:`${n.api.url}/v1/accounts/${n.api.account}`});return window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/auth/token`,{method:"POST",headers:t,body:r}).then(n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")})})(n).then(e=>{const t=v({Authorization:`${e.token_type} ${e.access_token}`},n);return n.api.discountId?window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules/${n.api.discountId}`,{headers:t}).then(n=>{if(200===n.status)return n.json().then(n=>[n]);throw new Error("Authentication failed")}):window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules?limit=${n.api.limit}`,{headers:t}).then(n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")})}),T=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`,q=(n,e)=>`\n.${n} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${n}:after {\n content: " ";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;const M={language:"no",version:"0.3.2",linkTarget:"_self",currency:{value:"Kr",position:"suffix",exponent:2},theme:{background:"#fff",primary:"#333",secondary:"#333",color:"inherit",borderRadius:"2px",fontSize:"inherit"},api:{account:"",key:"",secret:"",url:"https://api.dintero.com",limit:50}},z=(n,e)=>`\n.${n} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${e.fontSize};\n color: ${e.color};\n}`,E=(n,t)=>{const r=e({tag:"div",styles:[p,z],theme:n.theme});return t.forEach(e=>{const t=$(e,n),i=l(e);i&&(t.setAttribute("target",n?.linkTarget||"_self"),t.setAttribute("href",i.href)),r.appendChild(t)}),n.container.appendChild(r),{destroy:()=>{n.container.removeChild(r)}}};n.embed=async n=>{const t=(r=M,i=n,{...r,...i,currency:{...r.currency,...i.currency},theme:{...r.theme,...i.theme},api:{...r.api,...i.api}});var r,i;if(!t.container||!t.container.appendChild)throw console.error("Invalid configuration"),new Error("Invalid configuration");if(t.discounts)return E(t,t.discounts);{const r=(n=>e({tag:"div",styles:[p,q],theme:n.theme}))(t);try{n.container.appendChild(r);const e=await k(t);return t.container.removeChild(r),E(t,e)}catch(i){n.container.removeChild(r);const o=(n=>{const t=a[n.language];return e({tag:"div",styles:[p,T],theme:n.theme,innerHTML:t.errors.fetch})})(t);return t.container.appendChild(o),{destroy:()=>{n.container.removeChild(o)}}}}},Object.defineProperty(n,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=dintero-discounts-web-sdk.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dintero-discounts-web-sdk.umd.min.js","sources":["../src/dom.ts","../src/translations.ts","../src/formatters.ts","../src/normalize.ts","../src/discounts.ts","../src/fetch.ts","../src/error.ts","../src/loading.ts","../src/index.ts"],"sourcesContent":["import { Theme } from \"./types\";\n\ntype CreateElementOptions = {\n tag: string;\n attributes?: { [key: string]: any };\n styles?: ((className: string, theme?: Theme) => string)[];\n handlers?: { [key: string]: EventListenerOrEventListenerObject };\n innerHTML?: string;\n theme?: Theme;\n};\n\nexport const createElement = (options: CreateElementOptions) => {\n const elem = document.createElement(options.tag);\n if (options.attributes) {\n addAttributes(elem, options.attributes);\n }\n if (options.handlers) {\n addEventListeners(elem, options.handlers);\n }\n if (options.styles) {\n addStyles(elem, options.styles, options.theme);\n }\n if (options.innerHTML) {\n elem.innerHTML = options.innerHTML;\n }\n return elem;\n};\n\nconst addClass = (elem: HTMLElement, className: string) => {\n const names = elem.className.split(\" \");\n if (!names.includes(className)) {\n elem.className = elem.className + \" \" + className;\n }\n};\n\nconst hash = (input: string) => {\n let hash = 0;\n for (var i = 0; i < input.length; i++) {\n var char = input.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash.toString(36);\n};\n\nconst addStyles = (\n elem: HTMLElement,\n styles: ((className: string, theme?: Theme) => string)[],\n theme: Theme | undefined,\n) => {\n // \"styled components\" light\n styles.forEach((cssFn) => {\n // get class name from hash\n const className =\n \"dintero-deals-\" + hash(cssFn(\"dintero-deals\", theme));\n addClass(elem, className);\n // add style tag to DOM if not exists\n const hit = document.querySelector(`[data-css-hash=${className}]`);\n if (!hit) {\n const style = document.createElement(\"style\");\n style.innerHTML = cssFn(className, theme);\n style.setAttribute(\"data-css-hash\", className);\n document.head.appendChild(style);\n }\n });\n};\n\nconst addAttributes = (\n elem: HTMLElement,\n attributes: { [key: string]: string },\n) => {\n Object.keys(attributes).forEach((key) => {\n elem.setAttribute(key, attributes[key]);\n });\n};\n\nconst addEventListeners = (\n elem: HTMLElement,\n handlers: { [key: string]: EventListenerOrEventListenerObject },\n) => {\n Object.keys(handlers).forEach((key) => {\n elem.addEventListener(key, handlers[key]);\n });\n};\n","const no = {\n rewards: {\n discount_item_quantity: {\n three_for_two: \"3 for 2\",\n generic: \"Kjøp {{require}} betal for {{payFor}}\",\n },\n discount_amount: \"{{monetaryAmount}} rabatt\",\n },\n limitations: {\n discount_reward_usage:\n \"Antall: <strong>{{discount_reward_usage}}</strong>\",\n discount_repeat_usage:\n \"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>\",\n },\n requirements: {\n purchase_from: \"Tilbudet starter <strong>{{purchase_from}}</strong>\",\n purchase_to: \"Tilbudet utgår <strong>{{purchase_to}}</strong>\",\n },\n errors: {\n fetch: \"⚠️ <br/>En feil oppstod under lasting av tilbud...\",\n },\n};\n\nexport const translations = {\n no,\n};\n\nconst findValuesRegex = /(\\{\\{)[^}]*(\\}\\})/g;\n// i18n light\nexport const t = (\n translateString: string,\n values?: { [key: string]: any },\n): string => {\n const matches: string[] = translateString.match(findValuesRegex) || [];\n const _values = values || {};\n return matches.reduce<string>((interpolated, match) => {\n const key = match.replace(\"{{\", \"\").replace(\"}}\", \"\");\n const value = _values[key] || \"\";\n return interpolated.replace(match, value);\n }, translateString);\n};\n","import { Configuration } from \"./types\";\n\nexport const monetaryString = (\n amount: number,\n configuration: Configuration,\n options?: {\n decimal?: boolean;\n currency?: boolean;\n variant?: \"short\";\n },\n) => {\n const opt = options || {};\n const amountString = amount.toString();\n const dotIndex = amountString.length - configuration.currency.exponent;\n const beforeDot = amountString.slice(0, dotIndex) || \"0\";\n const afterDot = amountString.slice(dotIndex);\n const exponentAmount =\n afterDot == \"00\" && !opt.decimal\n ? beforeDot\n : beforeDot + \".\" + afterDot;\n if (opt.variant === \"short\" && afterDot === \"00\") {\n return beforeDot + \",-\";\n }\n if (!opt.currency) {\n return exponentAmount;\n }\n if (configuration.currency.position === \"prefix\") {\n return configuration.currency.value + \" \" + exponentAmount;\n }\n return exponentAmount + \" \" + configuration.currency.value;\n};\n\nconst padZero = (value: number) => {\n if (value < 10) {\n return `0${value}`;\n }\n return value.toString();\n};\n\nexport const dateString = (isoString: string, configuration: Configuration) => {\n try {\n const date = new Date(isoString);\n if (configuration.language === \"no\") {\n const dd = padZero(date.getDate());\n const mm = padZero(date.getMonth() + 1);\n const yyyy = date.getFullYear();\n return [dd, mm, yyyy].join(\".\");\n }\n return new Intl.DateTimeFormat().format(date);\n } catch (e) {\n return isoString.substr(0, 10);\n }\n};\n","export const normalize = (className: string) => `\n.${className} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`;\n","import { createElement } from \"./dom\";\nimport { Discount, Configuration, Theme } from \"./types\";\nimport { translations, t } from \"./translations\";\nimport { monetaryString, dateString } from \"./formatters\";\nimport { normalize } from \"./normalize\";\n\nexport const findWebshopLink = (discount: Discount) =>\n discount.links && discount.links.find((x) => x.rel && x.rel === \"webshop\");\n\nconst discountStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${theme.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${className} {\n width: 100%;\n max-width: 100%;\n } \n }\n`;\n\nconst imageWrapperStyles = (className: string) => `\n.${className} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`;\n\nconst imageStyle = (className: string) => `\n.${className} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`;\n\nconst ribbonTopStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${theme.borderRadius} ${theme.borderRadius} 0;\n padding: 5px 0;\n background: ${theme?.secondary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${theme.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst ribbonBottomStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${theme.borderRadius} 0 0 ${theme.borderRadius};\n padding: 5px 0;\n background: ${theme?.primary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${theme.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst titleStyle = (className: string) => `\n.${className} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`;\n\nconst subtitleStyle = (className: string) => `\n.${className} {\n margin-top: 0;\n}`;\n\nconst limitationsWrapperStyle = (className: string) => `\n.${className} {\n font-size: 0.75em;\n}\n.${className} > span{\n display: block;\n}\n`;\n\nconst getTopRibbonText = (discount: Discount) => {\n return (\n (discount && discount.metadata && discount.metadata.label) || undefined\n );\n};\n\nconst createTopRibbon = (discount: Discount, configuration: Configuration) => {\n const text = getTopRibbonText(discount);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonTopStyle],\n })\n );\n};\n\nconst getBottomRibbonText = (\n discount: Discount,\n configuration: Configuration,\n) => {\n const tStrings = translations[configuration.language];\n if (discount.reward.type === \"discount_item_new_price\") {\n return monetaryString(discount.reward.value, configuration, {\n variant: \"short\",\n });\n } else if (discount.reward.type === \"discount_percent\") {\n return discount.reward.value + \"%\";\n } else if (discount.reward.type === \"discount_item_quantity\") {\n if (\n discount.requirement.item.quantity === 3 &&\n discount.reward.value === 1\n ) {\n // Show custom 3 for 2 message\n return tStrings.rewards.discount_item_quantity.three_for_two;\n } else {\n const require = discount.requirement.item.quantity;\n const payFor =\n discount.requirement.item.quantity - discount.reward.value;\n return t(tStrings.rewards.discount_item_quantity.generic, {\n require,\n payFor,\n });\n }\n } else if (discount.reward.type === \"discount_amount\") {\n const monetaryAmount = monetaryString(\n discount.reward.value,\n configuration,\n { decimal: false },\n );\n return t(tStrings.rewards.discount_amount, { monetaryAmount });\n } else if (discount.reward.type === \"discount_item_percent\") {\n return discount.reward.value + \"%\";\n }\n return \"\";\n};\n\nconst createBottomRibbon = (\n discount: Discount,\n configuration: Configuration,\n) => {\n const text = getBottomRibbonText(discount, configuration);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonBottomStyle],\n })\n );\n};\n\nconst createImage = (discount: Discount) => {\n const imageWrapper = createElement({\n tag: \"div\",\n styles: [normalize, imageWrapperStyles],\n });\n const imageSrc = discount.links.find((link) => [\n \"medium_discount_image\",\n \"thumbnail_discount_image\".includes(link.rel),\n ]);\n const image =\n imageSrc &&\n createElement({\n tag: \"img\",\n attributes: {\n src: imageSrc.href,\n alt: discount.name,\n loading: \"lazy\",\n },\n styles: [normalize, imageStyle],\n });\n if (image) {\n imageWrapper.appendChild(image);\n }\n return imageWrapper;\n};\n\nconst createLimitations = (\n discount: Discount,\n configuration: Configuration,\n) => {\n const tStrings = translations[configuration.language];\n\n const wrapper = createElement({\n tag: \"small\",\n styles: [normalize, limitationsWrapperStyle],\n });\n\n const quantity =\n discount.limitation.discount_reward_usage &&\n discount.limitation.discount_reward_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_reward_usage, {\n discount_reward_usage:\n discount.limitation.discount_reward_usage,\n }),\n });\n const repeat =\n discount.limitation.discount_repeat_usage &&\n discount.limitation.discount_repeat_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_repeat_usage, {\n discount_repeat_usage:\n discount.limitation.discount_repeat_usage,\n }),\n });\n\n const startDate = new Date(discount.requirement.purchase_from || 0);\n const start =\n startDate > new Date() &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_from, {\n purchase_from: dateString(\n discount.requirement.purchase_from,\n configuration,\n ),\n }),\n });\n const endDate = new Date(discount.requirement.purchase_to || 0);\n const end =\n endDate > new Date() &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_to, {\n purchase_to: dateString(\n discount.requirement.purchase_to,\n configuration,\n ),\n }),\n });\n const children = [quantity, repeat, start, end].filter((child) => child);\n children.forEach((child) => wrapper.appendChild(child));\n return wrapper;\n};\n\nexport const createDiscount = (\n discount: Discount,\n configuration: Configuration,\n): HTMLElement => {\n const discountElem = createElement({\n tag: findWebshopLink(discount) ? \"a\" : \"div\",\n styles: [normalize, discountStyle],\n theme: configuration.theme,\n });\n const ribbonTop = createTopRibbon(discount, configuration);\n const ribbonBottom = createBottomRibbon(discount, configuration);\n const image = createImage(discount);\n const title =\n discount?.name &&\n createElement({\n tag: \"h4\",\n innerHTML: discount.name,\n styles: [titleStyle],\n });\n const subtitle =\n discount?.metadata?.subtitle &&\n createElement({\n tag: \"p\",\n innerHTML: discount.metadata.subtitle,\n styles: [subtitleStyle],\n });\n const description =\n discount.description &&\n createElement({ tag: \"p\", innerHTML: discount.description });\n\n const limitations = createLimitations(discount, configuration);\n // add children to discount wrapper\n const children = [\n ribbonTop,\n ribbonBottom,\n image,\n title,\n subtitle,\n description,\n limitations,\n ].filter((child) => child);\n children.forEach((child) => discountElem.appendChild(child));\n return discountElem;\n};\n","import { Configuration, Discount, TokenResponse } from \"./types\";\n\nconst createHeaders = (\n keyValues: { [key: string]: string },\n configuration: Configuration,\n) => {\n const headers: HeadersInit = new Headers();\n Object.entries({\n ...keyValues,\n \"Dintero-System-Name\": \"deals-web-sdk\",\n \"Dintero-System-Version\": configuration.version,\n }).forEach(([key, value]) => {\n headers.append(key, value);\n });\n return headers;\n};\n\nconst fetchAccessToken = (\n configuration: Configuration,\n): Promise<TokenResponse> => {\n if (!configuration.api) {\n throw new Error(\"Authentication configuration missing\");\n }\n const basicAuthCredentials = window.btoa(\n `${configuration.api.key}:${configuration.api.secret}`,\n );\n const headers = createHeaders(\n {\n Authorization: `Basic ${basicAuthCredentials}`,\n \"content-type\": \"application/json\",\n },\n configuration,\n );\n const body = JSON.stringify({\n grant_type: \"client_credentials\",\n audience: `${configuration.api.url}/v1/accounts/${configuration.api.account}`,\n });\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/auth/token`,\n {\n method: \"POST\",\n headers,\n body,\n },\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<TokenResponse>;\n }\n throw new Error(\"Authentication failed\");\n });\n};\n\nexport const fetchDiscounts = (\n configuration: Configuration,\n): Promise<Discount[]> => {\n return fetchAccessToken(configuration).then((tokenResponse) => {\n const headers = createHeaders(\n {\n Authorization: `${tokenResponse.token_type} ${tokenResponse.access_token}`,\n },\n configuration,\n );\n\n if (configuration.api.discountId) {\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules/${configuration.api.discountId}`,\n {\n headers,\n },\n )\n .then((response) => {\n if (response.status === 200) {\n return response\n .json()\n .then((discount) => [discount]) as Promise<\n Discount[]\n >;\n }\n throw new Error(\"Authentication failed\");\n });\n }\n\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules?limit=${configuration.api.limit}`,\n {\n headers,\n },\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<Discount[]>;\n }\n throw new Error(\"Authentication failed\");\n });\n });\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { translations } from \"./translations\";\nimport { normalize } from \"./normalize\";\n\nconst errorStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`;\n\nexport const createError = (configuration: Configuration): HTMLElement => {\n const tString = translations[configuration.language];\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, errorStyle],\n theme: configuration.theme,\n innerHTML: tString.errors.fetch,\n });\n\n return errorElem;\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { normalize } from \"./normalize\";\n\nconst loadingStyle = (className: string, theme: Theme) => `\n.${className} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${className}:after {\n content: \" \";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;\n\nexport const createLoading = (configuration: Configuration): HTMLElement => {\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, loadingStyle],\n theme: configuration.theme,\n });\n\n return errorElem;\n};\n","import { createDiscount, findWebshopLink } from \"./discounts\";\nimport { Discount, Configuration, Theme, Embed } from \"./types\";\nimport { createElement } from \"./dom\";\nimport { fetchDiscounts } from \"./fetch\";\nimport { createError } from \"./error\";\nimport { createLoading } from \"./loading\";\nimport { normalize } from \"./normalize\";\nimport pkg from \"../package.json\";\n\nconst defaultConfig: Partial<Configuration> = {\n language: \"no\",\n version: pkg?.version || \"SNAPSHOT\",\n linkTarget: \"_self\",\n currency: {\n value: \"Kr\",\n position: \"suffix\",\n exponent: 2,\n },\n theme: {\n background: \"#fff\",\n primary: \"#333\",\n secondary: \"#333\",\n color: \"inherit\",\n borderRadius: \"2px\",\n fontSize: \"inherit\",\n },\n api: {\n account: \"\",\n key: \"\",\n secret: \"\",\n url: \"https://api.dintero.com\",\n limit: 50,\n },\n};\n\nconst mergeConfig = (\n a: Partial<Configuration>,\n b: Configuration,\n): Configuration => {\n return {\n ...a,\n ...b,\n currency: {\n ...a.currency,\n ...b.currency,\n },\n theme: {\n ...a.theme,\n ...b.theme,\n },\n api: {\n ...a.api,\n ...b.api,\n },\n };\n};\n\nconst wrapperStyles = (className: string, theme: Theme) => `\n.${className} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${theme.fontSize};\n color: ${theme.color};\n}`;\n\nexport const embed = async (configuration: Configuration): Promise<Embed> => {\n const _configuration = mergeConfig(defaultConfig, configuration);\n if (!_configuration.container || !_configuration.container.appendChild) {\n console.error(\"Invalid configuration\");\n throw new Error(\"Invalid configuration\");\n }\n if (_configuration.discounts) {\n return renderDeals(_configuration, _configuration.discounts);\n } else {\n const loader = createLoading(_configuration);\n try {\n configuration.container.appendChild(loader);\n const discounts = await fetchDiscounts(_configuration);\n _configuration.container.removeChild(loader);\n return renderDeals(_configuration, discounts);\n } catch (error) {\n configuration.container.removeChild(loader);\n const errorMessage = createError(_configuration);\n _configuration.container.appendChild(errorMessage);\n return {\n destroy: () => {\n configuration.container.removeChild(errorMessage);\n },\n };\n }\n }\n};\n\nconst renderDeals = (\n configuration: Configuration,\n discounts: Discount[],\n): Embed => {\n const wrapper = createElement({\n tag: \"div\",\n styles: [normalize, wrapperStyles],\n theme: configuration.theme,\n });\n discounts.forEach((discount) => {\n const elem = createDiscount(discount, configuration);\n const webShopLink = findWebshopLink(discount);\n if (webShopLink) {\n elem.setAttribute(\"target\", configuration?.linkTarget || \"_self\");\n elem.setAttribute(\"href\", webShopLink.href);\n }\n wrapper.appendChild(elem);\n });\n configuration.container.appendChild(wrapper);\n return {\n destroy: () => {\n configuration.container.removeChild(wrapper);\n },\n };\n};\n"],"names":["createElement","options","elem","document","tag","attributes","addAttributes","handlers","addEventListeners","styles","addStyles","theme","innerHTML","forEach","cssFn","className","input","hash","i","length","charCodeAt","toString","addClass","split","includes","querySelector","style","setAttribute","head","appendChild","Object","keys","key","addEventListener","translations","no","rewards","discount_item_quantity","three_for_two","generic","discount_amount","limitations","discount_reward_usage","discount_repeat_usage","requirements","purchase_from","purchase_to","errors","fetch","findValuesRegex","t","translateString","values","matches","match","_values","reduce","interpolated","replace","value","monetaryString","amount","configuration","opt","amountString","dotIndex","currency","exponent","beforeDot","slice","afterDot","exponentAmount","decimal","variant","position","padZero","dateString","isoString","date","Date","language","dd","getDate","mm","getMonth","getFullYear","join","Intl","DateTimeFormat","format","e","substr","normalize","findWebshopLink","discount","links","find","x","rel","discountStyle","borderRadius","background","imageWrapperStyles","imageStyle","ribbonTopStyle","secondary","ribbonBottomStyle","primary","titleStyle","subtitleStyle","limitationsWrapperStyle","createBottomRibbon","text","getBottomRibbonText","tStrings","reward","type","requirement","item","quantity","require","payFor","monetaryAmount","createDiscount","discountElem","ribbonTop","createTopRibbon","metadata","label","undefined","getTopRibbonText","ribbonBottom","image","imageWrapper","imageSrc","link","src","href","alt","name","loading","createImage","title","subtitle","description","createLimitations","wrapper","limitation","filter","child","createHeaders","keyValues","headers","Headers","entries","version","append","fetchDiscounts","api","Error","basicAuthCredentials","window","btoa","secret","Authorization","body","JSON","stringify","grant_type","audience","url","account","method","then","response","status","json","fetchAccessToken","tokenResponse","token_type","access_token","discountId","limit","errorStyle","loadingStyle","defaultConfig","linkTarget","color","fontSize","wrapperStyles","renderDeals","discounts","webShopLink","container","destroy","removeChild","async","_configuration","a","b","mergeConfig","console","error","loader","createLoading","errorMessage","tString","createError"],"mappings":"iPAWO,MAAMA,EAAiBC,IAC1B,MAAMC,EAAOC,SAASH,cAAcC,EAAQG,KAa5C,OAZIH,EAAQI,YACRC,EAAcJ,EAAMD,EAAQI,YAE5BJ,EAAQM,UACRC,EAAkBN,EAAMD,EAAQM,UAEhCN,EAAQQ,QACRC,EAAUR,EAAMD,EAAQQ,OAAQR,EAAQU,OAExCV,EAAQW,YACRV,EAAKU,UAAYX,EAAQW,WAEtBV,CAAI,EAoBTQ,EAAYA,CACdR,EACAO,EACAE,KAGAF,EAAOI,SAASC,IAEZ,MAAMC,EACF,iBAnBEC,KACV,IAAIC,EAAO,EACX,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAMG,OAAQD,IAE9BD,GAAQA,GAAQ,GAAKA,EADVD,EAAMI,WAAWF,GAE5BD,GAAOA,EAEX,OAAOA,EAAKI,SAAS,GAAG,EAYGJ,CAAKH,EAAM,gBAAiBH,IA1B1CW,EAACpB,EAAmBa,KACnBb,EAAKa,UAAUQ,MAAM,KACxBC,SAAST,KAChBb,EAAKa,UAAYb,EAAKa,UAAY,IAAMA,EAC5C,EAuBIO,CAASpB,EAAMa,GAGf,IADYZ,SAASsB,cAAc,kBAAkBV,MAC3C,CACN,MAAMW,EAAQvB,SAASH,cAAc,SACrC0B,EAAMd,UAAYE,EAAMC,EAAWJ,GACnCe,EAAMC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ACxB,MAAMgJ,EAAU5K,EAAa4B,EAAckB,UAQ3C,OAPkBhF,EAAc,CAC5BI,IAAK,MACLK,OAAQ,CAACmF,EAAW2F,GACpB5K,MAAOmD,EAAcnD,MACrBC,UAAWkM,EAAQ/J,OAAOC,OAGd,EEuCa+J,CAAYV,GAEjC,OADAA,EAAeJ,UAAUpK,YAAYgL,GAC9B,CACHX,QAASA,KACLpI,EAAcmI,UAAUE,YAAYU,EAAa,EAG7D,CACJ"}
1
+ {"version":3,"file":"dintero-discounts-web-sdk.umd.min.js","sources":["../src/dom.ts","../src/translations.ts","../src/formatters.ts","../src/normalize.ts","../src/discounts.ts","../src/fetch.ts","../src/error.ts","../src/loading.ts","../src/index.ts"],"sourcesContent":["import { Theme } from \"./types\";\n\ntype CreateElementOptions = {\n tag: string;\n attributes?: { [key: string]: any };\n styles?: ((className: string, theme?: Theme) => string)[];\n handlers?: { [key: string]: EventListenerOrEventListenerObject };\n innerHTML?: string;\n theme?: Theme;\n};\n\nexport const createElement = (options: CreateElementOptions) => {\n const elem = document.createElement(options.tag);\n if (options.attributes) {\n addAttributes(elem, options.attributes);\n }\n if (options.handlers) {\n addEventListeners(elem, options.handlers);\n }\n if (options.styles) {\n addStyles(elem, options.styles, options.theme);\n }\n if (options.innerHTML) {\n elem.innerHTML = options.innerHTML;\n }\n return elem;\n};\n\nconst addClass = (elem: HTMLElement, className: string) => {\n const names = elem.className.split(\" \");\n if (!names.includes(className)) {\n elem.className = elem.className + \" \" + className;\n }\n};\n\nconst hash = (input: string) => {\n let hash = 0;\n for (var i = 0; i < input.length; i++) {\n var char = input.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash.toString(36);\n};\n\nconst addStyles = (\n elem: HTMLElement,\n styles: ((className: string, theme?: Theme) => string)[],\n theme: Theme | undefined,\n) => {\n // \"styled components\" light\n styles.forEach((cssFn) => {\n // get class name from hash\n const className =\n \"dintero-deals-\" + hash(cssFn(\"dintero-deals\", theme));\n addClass(elem, className);\n // add style tag to DOM if not exists\n const hit = document.querySelector(`[data-css-hash=${className}]`);\n if (!hit) {\n const style = document.createElement(\"style\");\n style.innerHTML = cssFn(className, theme);\n style.setAttribute(\"data-css-hash\", className);\n document.head.appendChild(style);\n }\n });\n};\n\nconst addAttributes = (\n elem: HTMLElement,\n attributes: { [key: string]: string },\n) => {\n Object.keys(attributes).forEach((key) => {\n elem.setAttribute(key, attributes[key]);\n });\n};\n\nconst addEventListeners = (\n elem: HTMLElement,\n handlers: { [key: string]: EventListenerOrEventListenerObject },\n) => {\n Object.keys(handlers).forEach((key) => {\n elem.addEventListener(key, handlers[key]);\n });\n};\n","const no = {\n rewards: {\n discount_item_quantity: {\n three_for_two: \"3 for 2\",\n generic: \"Kjøp {{require}} betal for {{payFor}}\",\n },\n discount_amount: \"{{monetaryAmount}} rabatt\",\n },\n limitations: {\n discount_reward_usage:\n \"Antall: <strong>{{discount_reward_usage}}</strong>\",\n discount_repeat_usage:\n \"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>\",\n },\n requirements: {\n purchase_from: \"Tilbudet starter <strong>{{purchase_from}}</strong>\",\n purchase_to: \"Tilbudet utgår <strong>{{purchase_to}}</strong>\",\n },\n errors: {\n fetch: \"⚠️ <br/>En feil oppstod under lasting av tilbud...\",\n },\n};\n\nexport const translations = {\n no,\n};\n\nconst findValuesRegex = /(\\{\\{)[^}]*(\\}\\})/g;\n// i18n light\nexport const t = (\n translateString: string,\n values?: { [key: string]: any },\n): string => {\n const matches: string[] = translateString.match(findValuesRegex) || [];\n const _values = values || {};\n return matches.reduce<string>((interpolated, match) => {\n const key = match.replace(\"{{\", \"\").replace(\"}}\", \"\");\n const value = _values[key] || \"\";\n return interpolated.replace(match, value);\n }, translateString);\n};\n","import { Configuration } from \"./types\";\n\nexport const monetaryString = (\n amount: number,\n configuration: Configuration,\n options?: {\n decimal?: boolean;\n currency?: boolean;\n variant?: \"short\";\n },\n) => {\n const opt = options || {};\n const amountString = amount.toString();\n const dotIndex = amountString.length - configuration.currency.exponent;\n const beforeDot = amountString.slice(0, dotIndex) || \"0\";\n const afterDot = amountString.slice(dotIndex);\n const exponentAmount =\n afterDot == \"00\" && !opt.decimal\n ? beforeDot\n : beforeDot + \".\" + afterDot;\n if (opt.variant === \"short\" && afterDot === \"00\") {\n return beforeDot + \",-\";\n }\n if (!opt.currency) {\n return exponentAmount;\n }\n if (configuration.currency.position === \"prefix\") {\n return configuration.currency.value + \" \" + exponentAmount;\n }\n return exponentAmount + \" \" + configuration.currency.value;\n};\n\nconst padZero = (value: number) => {\n if (value < 10) {\n return `0${value}`;\n }\n return value.toString();\n};\n\nexport const dateString = (isoString: string, configuration: Configuration) => {\n try {\n const date = new Date(isoString);\n if (configuration.language === \"no\") {\n const dd = padZero(date.getDate());\n const mm = padZero(date.getMonth() + 1);\n const yyyy = date.getFullYear();\n return [dd, mm, yyyy].join(\".\");\n }\n return new Intl.DateTimeFormat().format(date);\n } catch (e) {\n return isoString.substr(0, 10);\n }\n};\n","export const normalize = (className: string) => `\n.${className} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`;\n","import { createElement } from \"./dom\";\nimport { Discount, Configuration, Theme } from \"./types\";\nimport { translations, t } from \"./translations\";\nimport { monetaryString, dateString } from \"./formatters\";\nimport { normalize } from \"./normalize\";\n\nexport const findWebshopLink = (discount: Discount) =>\n discount.links && discount.links.find((x) => x.rel && x.rel === \"webshop\");\n\nconst discountStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${theme.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${className} {\n width: 100%;\n max-width: 100%;\n } \n }\n`;\n\nconst imageWrapperStyles = (className: string) => `\n.${className} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`;\n\nconst imageStyle = (className: string) => `\n.${className} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`;\n\nconst ribbonTopStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${theme.borderRadius} ${theme.borderRadius} 0;\n padding: 5px 0;\n background: ${theme?.secondary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${theme.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst ribbonBottomStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${theme.borderRadius} 0 0 ${theme.borderRadius};\n padding: 5px 0;\n background: ${theme?.primary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${theme.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst titleStyle = (className: string) => `\n.${className} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`;\n\nconst subtitleStyle = (className: string) => `\n.${className} {\n margin-top: 0;\n}`;\n\nconst limitationsWrapperStyle = (className: string) => `\n.${className} {\n font-size: 0.75em;\n}\n.${className} > span{\n display: block;\n}\n`;\n\nconst getTopRibbonText = (discount: Discount) => {\n return (\n (discount && discount.metadata && discount.metadata.label) || undefined\n );\n};\n\nconst createTopRibbon = (discount: Discount, configuration: Configuration) => {\n const text = getTopRibbonText(discount);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonTopStyle],\n })\n );\n};\n\nconst getBottomRibbonText = (\n discount: Discount,\n configuration: Configuration,\n) => {\n const tStrings = translations[configuration.language];\n if (discount.reward.type === \"discount_item_new_price\") {\n return monetaryString(discount.reward.value, configuration, {\n variant: \"short\",\n });\n } else if (discount.reward.type === \"discount_percent\") {\n return discount.reward.value + \"%\";\n } else if (discount.reward.type === \"discount_item_quantity\") {\n if (\n discount.requirement.item.quantity === 3 &&\n discount.reward.value === 1\n ) {\n // Show custom 3 for 2 message\n return tStrings.rewards.discount_item_quantity.three_for_two;\n } else {\n const require = discount.requirement.item.quantity;\n const payFor =\n discount.requirement.item.quantity - discount.reward.value;\n return t(tStrings.rewards.discount_item_quantity.generic, {\n require,\n payFor,\n });\n }\n } else if (discount.reward.type === \"discount_amount\") {\n const monetaryAmount = monetaryString(\n discount.reward.value,\n configuration,\n { decimal: false },\n );\n return t(tStrings.rewards.discount_amount, { monetaryAmount });\n } else if (discount.reward.type === \"discount_item_percent\") {\n return discount.reward.value + \"%\";\n }\n return \"\";\n};\n\nconst createBottomRibbon = (\n discount: Discount,\n configuration: Configuration,\n) => {\n const text = getBottomRibbonText(discount, configuration);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonBottomStyle],\n })\n );\n};\n\nconst createImage = (discount: Discount) => {\n const imageWrapper = createElement({\n tag: \"div\",\n styles: [normalize, imageWrapperStyles],\n });\n const imageSrc = discount.links.find((link) => [\n \"medium_discount_image\",\n \"thumbnail_discount_image\".includes(link.rel),\n ]);\n const image =\n imageSrc &&\n createElement({\n tag: \"img\",\n attributes: {\n src: imageSrc.href,\n alt: discount.name,\n loading: \"lazy\",\n },\n styles: [normalize, imageStyle],\n });\n if (image) {\n imageWrapper.appendChild(image);\n }\n return imageWrapper;\n};\n\nconst createLimitations = (\n discount: Discount,\n configuration: Configuration,\n) => {\n const tStrings = translations[configuration.language];\n\n const wrapper = createElement({\n tag: \"small\",\n styles: [normalize, limitationsWrapperStyle],\n });\n\n const quantity =\n discount.limitation.discount_reward_usage &&\n discount.limitation.discount_reward_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_reward_usage, {\n discount_reward_usage:\n discount.limitation.discount_reward_usage,\n }),\n });\n const repeat =\n discount.limitation.discount_repeat_usage &&\n discount.limitation.discount_repeat_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_repeat_usage, {\n discount_repeat_usage:\n discount.limitation.discount_repeat_usage,\n }),\n });\n\n const startDate = new Date(discount.requirement.purchase_from || 0);\n const start =\n startDate > new Date() &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_from, {\n purchase_from: dateString(\n discount.requirement.purchase_from,\n configuration,\n ),\n }),\n });\n const endDate = new Date(discount.requirement.purchase_to || 0);\n const end =\n endDate > new Date() &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_to, {\n purchase_to: dateString(\n discount.requirement.purchase_to,\n configuration,\n ),\n }),\n });\n const children = [quantity, repeat, start, end].filter((child) => child);\n children.forEach((child) => wrapper.appendChild(child));\n return wrapper;\n};\n\nexport const createDiscount = (\n discount: Discount,\n configuration: Configuration,\n): HTMLElement => {\n const discountElem = createElement({\n tag: findWebshopLink(discount) ? \"a\" : \"div\",\n styles: [normalize, discountStyle],\n theme: configuration.theme,\n });\n const ribbonTop = createTopRibbon(discount, configuration);\n const ribbonBottom = createBottomRibbon(discount, configuration);\n const image = createImage(discount);\n const title =\n discount?.name &&\n createElement({\n tag: \"h4\",\n innerHTML: discount.name,\n styles: [titleStyle],\n });\n const subtitle =\n discount?.metadata?.subtitle &&\n createElement({\n tag: \"p\",\n innerHTML: discount.metadata.subtitle,\n styles: [subtitleStyle],\n });\n const description =\n discount.description &&\n createElement({ tag: \"p\", innerHTML: discount.description });\n\n const limitations = createLimitations(discount, configuration);\n // add children to discount wrapper\n const children = [\n ribbonTop,\n ribbonBottom,\n image,\n title,\n subtitle,\n description,\n limitations,\n ].filter((child) => child);\n children.forEach((child) => discountElem.appendChild(child));\n return discountElem;\n};\n","import { Configuration, Discount, TokenResponse } from \"./types\";\n\nconst createHeaders = (\n keyValues: { [key: string]: string },\n configuration: Configuration,\n) => {\n const headers: HeadersInit = new Headers();\n Object.entries({\n ...keyValues,\n \"Dintero-System-Name\": \"deals-web-sdk\",\n \"Dintero-System-Version\": configuration.version,\n }).forEach(([key, value]) => {\n headers.append(key, value);\n });\n return headers;\n};\n\nconst fetchAccessToken = (\n configuration: Configuration,\n): Promise<TokenResponse> => {\n if (!configuration.api) {\n throw new Error(\"Authentication configuration missing\");\n }\n const basicAuthCredentials = window.btoa(\n `${configuration.api.key}:${configuration.api.secret}`,\n );\n const headers = createHeaders(\n {\n Authorization: `Basic ${basicAuthCredentials}`,\n \"content-type\": \"application/json\",\n },\n configuration,\n );\n const body = JSON.stringify({\n grant_type: \"client_credentials\",\n audience: `${configuration.api.url}/v1/accounts/${configuration.api.account}`,\n });\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/auth/token`,\n {\n method: \"POST\",\n headers,\n body,\n },\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<TokenResponse>;\n }\n throw new Error(\"Authentication failed\");\n });\n};\n\nexport const fetchDiscounts = (\n configuration: Configuration,\n): Promise<Discount[]> => {\n return fetchAccessToken(configuration).then((tokenResponse) => {\n const headers = createHeaders(\n {\n Authorization: `${tokenResponse.token_type} ${tokenResponse.access_token}`,\n },\n configuration,\n );\n\n if (configuration.api.discountId) {\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules/${configuration.api.discountId}`,\n {\n headers,\n },\n )\n .then((response) => {\n if (response.status === 200) {\n return response\n .json()\n .then((discount) => [discount]) as Promise<\n Discount[]\n >;\n }\n throw new Error(\"Authentication failed\");\n });\n }\n\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules?limit=${configuration.api.limit}`,\n {\n headers,\n },\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<Discount[]>;\n }\n throw new Error(\"Authentication failed\");\n });\n });\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { translations } from \"./translations\";\nimport { normalize } from \"./normalize\";\n\nconst errorStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`;\n\nexport const createError = (configuration: Configuration): HTMLElement => {\n const tString = translations[configuration.language];\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, errorStyle],\n theme: configuration.theme,\n innerHTML: tString.errors.fetch,\n });\n\n return errorElem;\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { normalize } from \"./normalize\";\n\nconst loadingStyle = (className: string, theme: Theme) => `\n.${className} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${className}:after {\n content: \" \";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;\n\nexport const createLoading = (configuration: Configuration): HTMLElement => {\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, loadingStyle],\n theme: configuration.theme,\n });\n\n return errorElem;\n};\n","import { createDiscount, findWebshopLink } from \"./discounts\";\nimport { Discount, Configuration, Theme, Embed } from \"./types\";\nimport { createElement } from \"./dom\";\nimport { fetchDiscounts } from \"./fetch\";\nimport { createError } from \"./error\";\nimport { createLoading } from \"./loading\";\nimport { normalize } from \"./normalize\";\nimport pkg from \"../package.json\";\n\nconst defaultConfig: Partial<Configuration> = {\n language: \"no\",\n version: pkg?.version || \"SNAPSHOT\",\n linkTarget: \"_self\",\n currency: {\n value: \"Kr\",\n position: \"suffix\",\n exponent: 2,\n },\n theme: {\n background: \"#fff\",\n primary: \"#333\",\n secondary: \"#333\",\n color: \"inherit\",\n borderRadius: \"2px\",\n fontSize: \"inherit\",\n },\n api: {\n account: \"\",\n key: \"\",\n secret: \"\",\n url: \"https://api.dintero.com\",\n limit: 50,\n },\n};\n\nconst mergeConfig = (\n a: Partial<Configuration>,\n b: Configuration,\n): Configuration => {\n return {\n ...a,\n ...b,\n currency: {\n ...a.currency,\n ...b.currency,\n },\n theme: {\n ...a.theme,\n ...b.theme,\n },\n api: {\n ...a.api,\n ...b.api,\n },\n };\n};\n\nconst wrapperStyles = (className: string, theme: Theme) => `\n.${className} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${theme.fontSize};\n color: ${theme.color};\n}`;\n\nexport const embed = async (configuration: Configuration): Promise<Embed> => {\n const _configuration = mergeConfig(defaultConfig, configuration);\n if (!_configuration.container || !_configuration.container.appendChild) {\n console.error(\"Invalid configuration\");\n throw new Error(\"Invalid configuration\");\n }\n if (_configuration.discounts) {\n return renderDeals(_configuration, _configuration.discounts);\n } else {\n const loader = createLoading(_configuration);\n try {\n configuration.container.appendChild(loader);\n const discounts = await fetchDiscounts(_configuration);\n _configuration.container.removeChild(loader);\n return renderDeals(_configuration, discounts);\n } catch (error) {\n configuration.container.removeChild(loader);\n const errorMessage = createError(_configuration);\n _configuration.container.appendChild(errorMessage);\n return {\n destroy: () => {\n configuration.container.removeChild(errorMessage);\n },\n };\n }\n }\n};\n\nconst renderDeals = (\n configuration: Configuration,\n discounts: Discount[],\n): Embed => {\n const wrapper = createElement({\n tag: \"div\",\n styles: [normalize, wrapperStyles],\n theme: configuration.theme,\n });\n discounts.forEach((discount) => {\n const elem = createDiscount(discount, configuration);\n const webShopLink = findWebshopLink(discount);\n if (webShopLink) {\n elem.setAttribute(\"target\", configuration?.linkTarget || \"_self\");\n elem.setAttribute(\"href\", webShopLink.href);\n }\n wrapper.appendChild(elem);\n });\n configuration.container.appendChild(wrapper);\n return {\n destroy: () => {\n configuration.container.removeChild(wrapper);\n },\n };\n};\n"],"names":["createElement","options","elem","document","tag","attributes","addAttributes","handlers","addEventListeners","styles","addStyles","theme","innerHTML","forEach","cssFn","className","input","hash","i","length","charCodeAt","toString","addClass","split","includes","querySelector","style","setAttribute","head","appendChild","Object","keys","key","addEventListener","translations","no","rewards","discount_item_quantity","three_for_two","generic","discount_amount","limitations","discount_reward_usage","discount_repeat_usage","requirements","purchase_from","purchase_to","errors","fetch","findValuesRegex","t","translateString","values","matches","match","_values","reduce","interpolated","replace","value","monetaryString","amount","configuration","opt","amountString","dotIndex","currency","exponent","beforeDot","slice","afterDot","exponentAmount","decimal","variant","position","padZero","dateString","isoString","date","Date","language","dd","getDate","mm","getMonth","getFullYear","join","Intl","DateTimeFormat","format","e","substr","normalize","findWebshopLink","discount","links","find","x","rel","discountStyle","borderRadius","background","imageWrapperStyles","imageStyle","ribbonTopStyle","secondary","ribbonBottomStyle","primary","titleStyle","subtitleStyle","limitationsWrapperStyle","createBottomRibbon","text","getBottomRibbonText","tStrings","reward","type","requirement","item","quantity","require","payFor","monetaryAmount","createDiscount","discountElem","ribbonTop","createTopRibbon","metadata","label","undefined","getTopRibbonText","ribbonBottom","image","imageWrapper","imageSrc","link","src","href","alt","name","loading","createImage","title","subtitle","description","createLimitations","wrapper","limitation","filter","child","createHeaders","keyValues","headers","Headers","entries","version","append","fetchDiscounts","api","Error","basicAuthCredentials","window","btoa","secret","Authorization","body","JSON","stringify","grant_type","audience","url","account","method","then","response","status","json","fetchAccessToken","tokenResponse","token_type","access_token","discountId","limit","errorStyle","loadingStyle","defaultConfig","linkTarget","color","fontSize","wrapperStyles","renderDeals","discounts","webShopLink","container","destroy","removeChild","async","_configuration","a","b","mergeConfig","console","error","loader","createLoading","errorMessage","tString","createError"],"mappings":"gPAWO,MAAMA,EAAiBC,IAC1B,MAAMC,EAAOC,SAASH,cAAcC,EAAQG,KAa5C,OAZIH,EAAQI,YACRC,EAAcJ,EAAMD,EAAQI,YAE5BJ,EAAQM,UACRC,EAAkBN,EAAMD,EAAQM,UAEhCN,EAAQQ,QACRC,EAAUR,EAAMD,EAAQQ,OAAQR,EAAQU,OAExCV,EAAQW,YACRV,EAAKU,UAAYX,EAAQW,WAEtBV,GAoBLQ,EAAYA,CACdR,EACAO,EACAE,KAGAF,EAAOI,QAASC,IAEZ,MAAMC,EACF,iBAnBEC,KACV,IAAIC,EAAO,EACX,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAMG,OAAQD,IAE9BD,GAAQA,GAAQ,GAAKA,EADVD,EAAMI,WAAWF,GAE5BD,GAAcA,EAElB,OAAOA,EAAKI,SAAS,KAYMJ,CAAKH,EAAM,gBAAiBH,IA1B1CW,EAACpB,EAAmBa,KACn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AAgBN,EACtC,CAAC,MAAOW,GACL5I,EAAcmI,UAAUE,YAAYQ,GACpC,MAAME,EFhDU/I,KACxB,MAAMgJ,EAAU5K,EAAa4B,EAAckB,UAQ3C,OAPkBhF,EAAc,CAC5BI,IAAK,MACLK,OAAQ,CAACmF,EAAW2F,GACpB5K,MAAOmD,EAAcnD,MACrBC,UAAWkM,EAAQ/J,OAAOC,SE0CD+J,CAAYV,GAEjC,OADAA,EAAeJ,UAAUpK,YAAYgL,GAC9B,CACHX,QAASA,KACLpI,EAAcmI,UAAUE,YAAYU,IAGhD,CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dintero/discounts-web-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Dintero Discounts SDK for web frontends",
5
5
  "main": "dist/dintero-discounts-web-sdk.cjs.js",
6
6
  "module": "dist/dintero-discounts-web-sdk.esm.js",
@@ -30,14 +30,14 @@
30
30
  "url": "https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "7.28.4",
34
- "@babel/preset-typescript": "7.27.1",
33
+ "@babel/core": "7.28.6",
34
+ "@babel/preset-typescript": "7.28.5",
35
35
  "@preconstruct/cli": "2.8.12",
36
36
  "@semantic-release/git": "10.0.1",
37
- "happy-dom": "20.0.8",
38
- "prettier": "3.6.2",
39
- "semantic-release": "25.0.1",
37
+ "happy-dom": "20.3.3",
38
+ "prettier": "3.8.0",
39
+ "semantic-release": "25.0.2",
40
40
  "typescript": "5.9.3",
41
- "vitest": "4.0.1"
41
+ "vitest": "4.0.17"
42
42
  }
43
43
  }