shopar-plugin 0.0.2 → 0.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/README.md CHANGED
@@ -32,7 +32,7 @@ There are two distinct ways of integrating the plugin: via Script tag and via NP
32
32
  Add the following script to your HTML.
33
33
 
34
34
  ```html
35
- <script src="https://cdn.jsdelivr.net/npm/shopar-plugin@0.0.2/dist/shopar-plugin.js"></script>
35
+ <script src="https://cdn.jsdelivr.net/npm/shopar-plugin@0.0.3/dist/shopar-plugin.js"></script>
36
36
  ```
37
37
 
38
38
  It is possible to use a different CDN instead of [jsDelivr](https://www.jsdelivr.com/) (e.g. [cdnjs](https://cdnjs.com/), [unpkg](https://www.unpkg.com/)), or even a relative path if the plugin is distributed as a static asset to your app. Just make sure to set the `baseUrl` parameter accordingly (see [setup options](#shoparpluginsetupoptions) for more details).
@@ -74,9 +74,6 @@ To change the look-and-feel of the plugin's UI, modify the following CSS classes
74
74
  .shopar-btn {
75
75
  /* Control button. */
76
76
  }
77
- .shopar-btn.active {
78
- /* Toggled control button. */
79
- }
80
77
  ```
81
78
 
82
79
  ## API
@@ -99,7 +96,7 @@ Options used for the plugin setup:
99
96
  - `baseUrl` (optional)
100
97
  - Type: `string`
101
98
  - If provided, defines where the additional ShopAR plugin files are fetched from.
102
- - Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@0.0.2/dist`
99
+ - Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@0.0.3/dist`
103
100
 
104
101
  ## License
105
102
 
@@ -0,0 +1 @@
1
+ <svg width="1.75rem" height="1.75rem" stroke="url(#SexyClose_linear0)" fill="none" stroke-width="0" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6.2253 4.81108C5.83477 4.42056 5.20161 4.42056 4.81108 4.81108C4.42056 5.20161 4.42056 5.83477 4.81108 6.2253L10.5858 12L4.81114 17.7747C4.42062 18.1652 4.42062 18.7984 4.81114 19.1889C5.20167 19.5794 5.83483 19.5794 6.22535 19.1889L12 13.4142L17.7747 19.1889C18.1652 19.5794 18.7984 19.5794 19.1889 19.1889C19.5794 18.7984 19.5794 18.1652 19.1889 17.7747L13.4142 12L19.189 6.2253C19.5795 5.83477 19.5795 5.20161 19.189 4.81108C18.7985 4.42056 18.1653 4.42056 17.7748 4.81108L12 10.5858L6.2253 4.81108Z" fill="url(#SexyClose_linear0)"></path><defs><linearGradient id="SexyClose_linear0" x1="19" y1="5" x2="5" y2="19" gradientUnits="userSpaceOnUse"><stop stop-color="#5FB9EC"></stop><stop offset="1" stop-color="#773CD8"></stop></linearGradient></defs></svg>
@@ -0,0 +1 @@
1
+ <svg width="1.75rem" height="1.75rem" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M652.836 125.898L534.5 78.4999C515.728 70.9921 483.772 70.992 465 78.4998L92.5 228C87.6339 229.95 77.4381 238.158 74.5 242.5C71.5619 246.842 70.0012 256.258 70 261.5V715C70.0108 725.497 74.0515 741.815 79.9473 750.5C85.843 759.185 100.748 770.616 110.5 774.5L481 925C487.268 927.512 511.232 927.512 517.5 925L890 775.5C899.742 771.608 914.114 760.684 920 752C925.886 743.316 929.993 726.946 930 716.455V261.5C929.999 256.331 927.509 245.645 924.623 241.186C915.537 246.4 908.48 254.671 904.802 264.645L875.721 343.507C872.03 353.517 865.669 360.973 858 365.876V709L537 838L534.5 444L790.668 341.85L765.593 273.852L500 380L204.5 261.5L491.5 146.5C497.768 143.988 502.732 143.988 509 146.5L641.44 199.476C619.316 179.062 623.114 139.86 652.836 125.898ZM464 444V838L142.5 709V315L464 444Z" fill="url(#SexyCube_linear0)"></path><path d="M817.671 42.241C823.04 27.7308 843.563 27.7308 848.932 42.241L875.657 114.463C877.345 119.025 880.942 122.622 885.504 124.31L957.726 151.034C972.236 156.404 972.236 176.927 957.726 182.296L885.504 209.021C880.942 210.709 877.345 214.305 875.657 218.867L848.932 291.089C843.563 305.6 823.04 305.6 817.671 291.089L790.946 218.867C789.258 214.305 785.661 210.709 781.099 209.021L708.877 182.296C694.366 176.927 694.366 156.404 708.877 151.034L781.099 124.31C785.661 122.622 789.258 119.025 790.946 114.463L817.671 42.241Z" fill="url(#SexyCube_linear0)"></path><defs><linearGradient id="SexyCube_linear0" x1="519.304" y1="31.3584" x2="-74.0195" y2="405.753" gradientUnits="userSpaceOnUse"><stop stop-color="#5FB9EC"></stop><stop offset="1" stop-color="#773CD8"></stop></linearGradient></defs></svg>
@@ -0,0 +1 @@
1
+ <svg width="1.75rem" height="1.75rem" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M732.747 96.674C715.401 86.7011 697.393 77.8352 678.829 70.1455C622.311 46.7354 561.736 34.6863 500.562 34.6863C377.015 34.6863 258.529 83.7647 171.168 171.125C83.8072 258.485 34.7285 376.971 34.7285 500.516C34.7285 624.062 83.8073 742.548 171.168 829.908C258.529 917.268 377.015 966.346 500.562 966.346C561.736 966.346 622.311 954.297 678.829 930.887C735.346 907.477 786.7 873.164 829.956 829.908C873.213 786.652 907.526 735.299 930.936 678.782C954.347 622.265 966.396 561.69 966.396 500.516C966.396 439.343 954.347 378.768 930.936 322.251C922.997 303.084 913.804 284.511 903.433 266.646L874.721 344.507C871.656 352.819 866.749 359.371 860.782 364.161C877.263 407.7 885.726 453.898 885.726 500.516C885.726 551.097 875.764 601.181 856.407 647.911C837.051 694.641 808.68 737.101 772.914 772.867C737.148 808.632 694.688 837.003 647.958 856.359C601.228 875.715 551.143 885.678 500.562 885.678C398.41 885.678 300.442 845.098 228.21 772.867C155.978 700.635 115.398 602.668 115.398 500.516C115.398 398.365 155.978 300.398 228.21 228.166C300.442 155.935 398.41 115.355 500.562 115.355C546.71 115.355 592.445 123.648 635.596 139.802C640.407 133.595 647.079 128.483 655.614 125.314L732.747 96.674Z" fill="url(#SexyGlasses_linear0)"></path><path d="M779.991 316.608C778.351 316.446 776.687 316.363 775.004 316.363L224.153 316.363C196.539 316.363 174.153 338.749 174.153 366.363V485.351C174.165 506.451 182.556 526.683 197.481 541.599C212.405 556.514 232.642 564.893 253.743 564.893H387.818C408.919 564.893 429.156 556.514 444.08 541.599C459.005 526.683 467.396 506.451 467.408 485.351V418.267C467.408 400.5 481.811 386.097 499.579 386.097C517.346 386.097 531.749 400.5 531.749 418.267V485.351C531.762 506.451 540.152 526.683 555.077 541.599C570.002 556.514 590.239 564.893 611.339 564.893H745.461C766.553 564.881 786.778 556.497 801.693 541.582C816.608 526.668 824.992 506.443 825.004 485.351V373.332C810.201 370.922 796.477 361.314 790.279 344.507L779.991 316.608Z" fill="url(#SexyGlasses_linear0)"></path><path d="M657.603 629.425C677.299 639.43 685.155 663.507 675.15 683.203L640.224 665.462C675.15 683.203 675.14 683.224 675.129 683.245L675.059 683.381C675.026 683.445 674.991 683.513 674.953 683.586C674.877 683.732 674.792 683.894 674.696 684.074C674.592 684.27 674.476 684.485 674.348 684.72C674.241 684.917 674.125 685.127 674 685.35C673.454 686.33 672.74 687.564 671.848 689.015C670.066 691.915 667.561 695.704 664.252 700.078C657.647 708.806 647.725 720.012 633.824 731.098C605.528 753.663 562.13 774.562 500.537 774.562C439.002 774.562 395.616 753.694 367.318 731.173C353.414 720.108 343.484 708.922 336.871 700.209C333.558 695.844 331.049 692.061 329.264 689.167C328.37 687.718 327.654 686.486 327.107 685.508C326.833 685.019 326.601 684.593 326.41 684.235C326.314 684.055 326.228 683.893 326.152 683.748C326.114 683.675 326.079 683.607 326.046 683.543L325.999 683.451L325.976 683.407C325.965 683.386 325.955 683.365 361.586 665.188L325.955 683.365C315.916 663.687 323.73 639.596 343.409 629.557C362.912 619.607 386.749 627.195 396.945 646.487C396.958 646.509 396.973 646.536 396.992 646.567C397.025 646.625 397.068 646.698 397.122 646.788C397.157 646.847 397.196 646.913 397.24 646.985C397.276 647.043 397.313 647.105 397.354 647.171C397.909 648.071 398.974 649.708 400.597 651.846C403.856 656.141 409.246 662.299 417.135 668.577C432.422 680.743 458.512 694.563 500.537 694.563C542.604 694.563 568.681 680.724 583.945 668.552C591.824 662.269 597.203 656.106 600.455 651.808C602.074 649.668 603.136 648.03 603.689 647.13C603.901 646.786 604.036 646.553 604.096 646.447C614.26 627.137 638.083 619.51 657.603 629.425Z" fill="url(#SexyGlasses_linear0)"></path><path d="M817.684 42.241C823.053 27.7308 843.576 27.7309 848.946 42.2411L875.67 114.463C877.358 119.025 880.955 122.622 885.517 124.31L957.74 151.034C972.25 156.404 972.25 176.927 957.74 182.296L885.517 209.021C880.955 210.709 877.358 214.305 875.67 218.867L848.946 291.089C843.576 305.6 823.053 305.6 817.684 291.089L790.959 218.867C789.271 214.305 785.674 210.709 781.112 209.021L708.89 182.296C694.38 176.927 694.38 156.404 708.89 151.034L781.112 124.31C785.674 122.622 789.271 119.025 790.959 114.463L817.684 42.241Z" fill="url(#SexyGlasses_linear0)"></path><defs><linearGradient id="SexyGlasses_linear0" x1="501.675" y1="31.3584" x2="-116.561" y2="419.679" gradientUnits="userSpaceOnUse"><stop stop-color="#5FB9EC"></stop><stop offset="1" stop-color="#773CD8"></stop></linearGradient></defs></svg>
@@ -0,0 +1 @@
1
+ <svg width="1.75rem" height="1.75rem" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M375.945 103.513C375.945 103.513 375.971 103.546 376.02 103.622C375.97 103.553 375.945 103.513 375.945 103.513ZM383.147 122.126C364.836 137.445 291.121 198.101 211.827 249.262C196.893 258.898 177.868 270.218 162.49 279.185C167.379 288.916 174.623 301.742 185.292 317.939C219.46 369.809 287.812 454.819 423.401 581.748C559.625 709.27 645.987 776.392 703.168 813.185C755.787 847.042 783.555 855.206 804.977 861.505C806.229 861.873 807.46 862.235 808.672 862.595C827.524 868.195 846.928 869.733 863.69 868.234C876.032 867.131 885.262 864.552 891.278 861.986C873.67 839.813 784.762 726.135 742.558 638.355C728.353 608.809 715.828 574.716 704.93 539.506L626.141 558.549C604.668 563.74 583.053 550.54 577.863 529.066C572.673 507.593 585.873 485.979 607.346 480.789L683.736 462.325C681.381 452.693 679.146 443.166 677.03 433.813L599.786 452.483C578.313 457.673 556.698 444.473 551.508 423C546.318 401.527 559.518 379.912 580.991 374.722L661.002 355.384C658.68 342.753 656.674 331.199 654.981 321.045C572.487 337.574 496.132 301.691 438.463 236.535C407.644 201.715 393.567 155.957 385.175 128.678C384.46 126.354 383.786 124.164 383.147 122.126ZM94.1261 226.194C94.4662 226.002 94.9753 225.715 95.6373 225.34C96.9614 224.591 98.8963 223.493 101.314 222.114C106.152 219.355 112.908 215.48 120.562 211.025C136.02 202.028 154.588 190.987 168.455 182.04C254.836 126.307 335.203 57.9174 335.591 57.5872L335.592 57.5863C345.786 48.8913 356.828 41.0628 368.697 36.285C381.234 31.2388 397.091 28.7394 413.43 35.0251C428.918 40.9836 438.308 52.3916 443.786 61.1024C449.264 69.8155 453.104 79.4872 455.981 87.5943C458.981 96.0484 461.597 104.299 464.141 112.317C472.583 138.937 480.217 163.005 498.369 183.513C547.785 239.345 603.75 256.988 659.507 236.921C688.673 226.424 724.015 243.652 729.178 278.149C737.183 331.631 765.76 501.988 814.658 603.69C854.971 687.537 946.657 803.156 956.033 814.877C970.07 830.607 979.692 851.561 975.885 875.283C972.557 896.015 960.142 911.243 947.013 921.467C902.976 969.302 827.696 976.387 767.181 960.896C727.238 950.671 674.972 925.733 614.787 888.964C553.91 851.772 482.617 801.035 404.215 737.139C291.495 645.276 262.184 614.634 66.9688 402.701L66.4637 402.152L65.9794 401.585C49.9456 382.821 36.7643 366.245 28.2656 351.494C19.9902 337.131 11.5291 316.675 18.1171 293.707C24.2894 272.188 40.8938 259.312 51.5642 251.924C59.8866 246.163 70.7522 239.833 81.7078 233.451C85.4448 231.274 89.1922 229.091 92.8526 226.923L93.2383 226.694L94.1261 226.194Z" fill="url(#SexyShoe_linear0)"></path><path d="M817.67 47.2409C823.039 32.7307 843.562 32.7307 848.931 47.2409L875.656 119.463C877.344 124.025 880.941 127.622 885.503 129.31L957.725 156.034C972.236 161.404 972.236 181.927 957.725 187.296L885.503 214.02C880.941 215.708 877.344 219.305 875.656 223.867L848.931 296.089C843.562 310.599 823.039 310.599 817.67 296.089L790.945 223.867C789.257 219.305 785.66 215.708 781.098 214.02L708.876 187.296C694.365 181.927 694.365 161.404 708.876 156.034L781.098 129.31C785.66 127.622 789.257 124.025 790.945 119.463L817.67 47.2409Z" fill="url(#SexyShoe_linear0)"></path><defs><linearGradient id="SexyShoe_linear0" x1="496.241" y1="31.292" x2="-130.281" y2="435.37" gradientUnits="userSpaceOnUse"><stop stop-color="#5FB9EC"></stop><stop offset="1" stop-color="#773CD8"></stop></linearGradient></defs></svg>
@@ -0,0 +1 @@
1
+ <svg width="1.75rem" height="1.75rem" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M473.333 353.775C473.333 334.445 457.663 318.775 438.333 318.775C419.003 318.775 403.333 334.445 403.333 353.775V500.351C403.333 509.634 407.021 518.536 413.584 525.1L499.806 611.321C513.474 624.989 535.635 624.989 549.303 611.321C562.971 597.653 562.971 575.492 549.303 561.824L473.333 485.854V353.775Z" fill="url(#SexyWatch_linear0)"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M644.198 102.459C642.882 95.1828 640.789 88.0506 637.946 81.1867C632.721 68.5718 625.062 57.1094 615.407 47.4541C605.752 37.799 594.289 30.1401 581.674 24.9148C569.059 19.6894 555.538 17 541.884 17H334.953C307.377 17 280.93 27.9547 261.43 47.4541C241.931 66.9536 230.976 93.4005 230.976 120.977V224.188C218.043 233.901 205.735 244.567 194.164 256.138C129.39 320.912 93 408.765 93 500.369C93 591.974 129.39 679.827 194.164 744.601C205.735 756.172 218.043 766.838 230.976 776.551V879.704C230.976 907.28 241.931 933.727 261.43 953.226C280.93 972.726 307.377 983.68 334.953 983.68H541.884C555.538 983.68 569.059 980.991 581.674 975.766C594.289 970.54 605.751 962.882 615.407 953.226C625.062 943.571 632.721 932.109 637.946 919.494C643.171 906.879 645.861 893.358 645.861 879.704V776.518C658.778 766.813 671.07 756.159 682.628 744.601C747.402 679.827 783.792 591.974 783.792 500.369C783.792 460.586 776.929 421.509 763.857 384.724C749.051 382.316 735.323 372.708 729.124 355.899L698.659 273.296C690.344 257.875 682.344 248.875 665.632 240.249L582.975 209.561C566.27 203.36 555.344 190.375 554.261 174.987C552.038 143.375 561.344 137.375 575.861 128.505C578.068 127.243 580.439 126.13 582.975 125.189L644.198 102.459ZM243.662 305.635C295.308 253.988 365.357 224.973 438.396 224.973C511.436 224.973 581.484 253.988 633.131 305.635C684.777 357.282 713.792 427.33 713.792 500.369C713.792 573.409 684.777 643.457 633.131 695.104C581.484 746.751 511.436 775.766 438.396 775.766C365.357 775.766 295.308 746.751 243.662 695.104C192.015 643.457 163 573.409 163 500.369C163 427.33 192.015 357.282 243.662 305.635Z" fill="url(#SexyWatch_linear0)"></path><path d="M756.014 42.6159C761.383 28.1057 781.906 28.1057 787.275 42.6159L814 114.838C815.688 119.4 819.285 122.997 823.847 124.685L896.069 151.409C910.58 156.779 910.58 177.302 896.069 182.671L823.847 209.395C819.285 211.083 815.688 214.68 814 219.242L787.275 291.464C781.906 305.974 761.383 305.974 756.014 291.464L729.289 219.242C727.601 214.68 724.004 211.083 719.442 209.395L647.22 182.671C632.71 177.302 632.71 156.779 647.22 151.409L719.442 124.685C724.004 122.997 727.601 119.4 729.289 114.838L756.014 42.6159Z" fill="url(#SexyWatch_linear0)"></path><defs><linearGradient id="SexyWatch_linear0" x1="499.976" y1="17" x2="-86.9029" y2="327.748" gradientUnits="userSpaceOnUse"><stop stop-color="#5FB9EC"></stop><stop offset="1" stop-color="#773CD8"></stop></linearGradient></defs></svg>
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR__analytics={})}(this,(function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return i=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)};function r(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function o(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{a(i.next(e))}catch(e){o(e)}}function u(e){try{a(i.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((i=i.apply(e,t||[])).next())}))}function s(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&u[0]?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,i=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=t.call(e,s)}catch(e){u=[6,e],i=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var l,d,f,p,v;!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(l||(l={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(d||(d={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(f||(f={})),function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(p||(p={})),function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(v||(v={}));var h=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=v.Unknown),{event:e,code:t,message:n}},g=function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,g)},y=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[]}return e.prototype.register=function(e,t){var n,i,r;return o(this,void 0,void 0,(function(){return s(this,(function(o){switch(o.label){case 0:return e.name=null!==(n=e.name)&&void 0!==n?n:g(),e.type=null!==(i=e.type)&&void 0!==i?i:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)];case 1:return o.sent(),this.plugins.push(e),[2]}}))}))},e.prototype.deregister=function(e){var t;return o(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:return n=this.plugins.findIndex((function(t){return t.name===e})),i=this.plugins[n],this.plugins.splice(n,1),[4,null===(t=i.teardown)||void 0===t?void 0:t.call(i)];case 1:return r.sent(),[2]}}))}))},e.prototype.reset=function(e){this.applying=!1,this.plugins.map((function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.call(e)})),this.plugins=[],this.client=e},e.prototype.push=function(e){var t=this;return new Promise((function(n){t.queue.push([e,n]),t.scheduleApply(0)}))},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout((function(){t.apply(t.queue.shift()).then((function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)}))}),e))},e.prototype.apply=function(e){return o(this,void 0,void 0,(function(){var t,n,r,o,c,l,d,f,p,v,g,y,m,b,I,_,w,S,E,T;return s(this,(function(s){switch(s.label){case 0:if(!e)return[2];t=a(e,1),n=t[0],r=a(e,2),o=r[1],c=this.plugins.filter((function(e){return"before"===e.type})),s.label=1;case 1:s.trys.push([1,6,7,8]),l=u(c),d=l.next(),s.label=2;case 2:return d.done?[3,5]:(y=d.value).execute?[4,y.execute(i({},n))]:[3,4];case 3:if(null===(m=s.sent()))return o({event:n,code:0,message:""}),[2];n=m,s.label=4;case 4:return d=l.next(),[3,2];case 5:return[3,8];case 6:return f=s.sent(),w={error:f},[3,8];case 7:try{d&&!d.done&&(S=l.return)&&S.call(l)}finally{if(w)throw w.error}return[7];case 8:p=this.plugins.filter((function(e){return"enrichment"===e.type||void 0===e.type})),s.label=9;case 9:s.trys.push([9,14,15,16]),v=u(p),g=v.next(),s.label=10;case 10:return g.done?[3,13]:(y=g.value).execute?[4,y.execute(i({},n))]:[3,12];case 11:if(null===(m=s.sent()))return o({event:n,code:0,message:""}),[2];n=m,s.label=12;case 12:return g=v.next(),[3,10];case 13:return[3,16];case 14:return b=s.sent(),E={error:b},[3,16];case 15:try{g&&!g.done&&(T=v.return)&&T.call(v)}finally{if(E)throw E.error}return[7];case 16:return I=this.plugins.filter((function(e){return"destination"===e.type})),_=I.map((function(e){var t=i({},n);return e.execute(t).catch((function(e){return h(t,0,String(e))}))})),Promise.all(_).then((function(e){var t=a(e,1)[0]||h(n,100,"Event not tracked, no destination plugins on the instance");o(t)})),[2]}}))}))},e.prototype.flush=function(){return o(this,void 0,void 0,(function(){var e,t,n,i=this;return s(this,(function(r){switch(r.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map((function(e){return i.apply(e)})))];case 1:return r.sent(),t=this.plugins.filter((function(e){return"destination"===e.type})),n=t.map((function(e){return e.flush&&e.flush()})),[4,Promise.all(n)];case 2:return r.sent(),[2]}}))}))},e}(),m="AMP",b="".concat(m,"_unsent"),I="https://api2.amplitude.com/2/httpapi",_=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!w(t,n))return!1}return!0},w=function(e,t){var n,i;if("string"!=typeof e)return!1;if(Array.isArray(t)){var r=!0;try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(Array.isArray(a))return!1;if("object"==typeof a)r=r&&_(a);else if(!["number","string"].includes(typeof a))return!1;if(!r)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return _(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},S=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return i({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(l.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(l.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(l.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(l.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(l.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(l.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(l.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(l.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(l.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[l.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var i=this._properties[e];return void 0===i&&(i={},this._properties[e]=i),i[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return void 0===this._properties[l.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===l.ADD?"number"==typeof n:e===l.UNSET||e===l.REMOVE||w(t,n)))},e}(),E=function(e,t){return i(i({},t),{event_type:f.IDENTIFY,user_properties:e.getUserProperties()})},T=function(e){return{promise:e||Promise.resolve()}},O=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new y(this),this.name=e}return e.prototype._init=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),[4,this.runQueuedFunctions("q")];case 1:return t.sent(),[2]}}))}))},e.prototype.runQueuedFunctions=function(e){return o(this,void 0,void 0,(function(){var t,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:t=this[e],this[e]=[],s.label=1;case 1:s.trys.push([1,6,7,8]),n=u(t),i=n.next(),s.label=2;case 2:return i.done?[3,5]:[4,(0,i.value)()];case 3:s.sent(),s.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return r=s.sent(),o={error:r},[3,8];case 7:try{i&&!i.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},e.prototype.track=function(e,t,n){var r=function(e,t,n){return i(i(i({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return T(this.dispatch(r))},e.prototype.identify=function(e,t){var n=E(e,t);return T(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var o=function(e,t,n,r){var o;return i(i({},r),{event_type:f.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(o={},o[e]=t,o)})}(e,t,n,r);return T(this.dispatch(o))},e.prototype.setGroup=function(e,t,n){var r=function(e,t,n){var r,o=new S;return o.set(e,t),i(i({},n),{event_type:f.IDENTIFY,user_properties:o.getUserProperties(),groups:(r={},r[e]=t,r)})}(e,t,n);return T(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=function(e,t){return i(i({},t),{event_type:f.REVENUE,event_properties:e.getEventProperties()})}(e,t);return T(this.dispatch(n))},e.prototype.add=function(e){return this.config?T(this.timeline.register(e,this.config)):(this.q.push(this.add.bind(this,e)),T())},e.prototype.remove=function(e){return this.config?T(this.timeline.deregister(e)):(this.q.push(this.remove.bind(this,e)),T())},e.prototype.dispatchWithCallback=function(e,t){if(!this.config)return t(h(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return o(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){return this.config?[2,this.process(e)]:[2,new Promise((function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))}))]}))}))},e.prototype.process=function(e){return o(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.config.optOut?[2,h(e,0,"Event skipped due to optOut config")]:[4,this.timeline.push(e)];case 1:return 200===(i=r.sent()).code?this.config.loggerProvider.log(i.message):100===i.code?this.config.loggerProvider.warn(i.message):this.config.loggerProvider.error(i.message),[2,i];case 2:return t=r.sent(),n=String(t),this.config.loggerProvider.error(n),[2,i=h(e,0,n)];case 3:return[2]}}))}))},e.prototype.setOptOut=function(e){this.config?this.config.optOut=Boolean(e):this.q.push(this.setOptOut.bind(this,Boolean(e)))},e.prototype.flush=function(){return T(this.timeline.flush())},e}(),k=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setEventProperties=function(e){return _(e)&&(this.properties=e),this},e.prototype.getEventProperties=function(){var e=this.properties?i({},this.properties):{};return e[d.REVENUE_PRODUCT_ID]=this.productId,e[d.REVENUE_QUANTITY]=this.quantity,e[d.REVENUE_PRICE]=this.price,e[d.REVENUE_TYPE]=this.revenueType,e[d.REVENUE]=this.revenue,e},e}(),P="Amplitude Logger ",R=function(){function e(){this.logLevel=p.None}return e.prototype.disable=function(){this.logLevel=p.None},e.prototype.enable=function(e){void 0===e&&(e=p.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<p.Verbose||console.log("".concat(P,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<p.Warn||console.warn("".concat(P,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<p.Error||console.error("".concat(P,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<p.Debug||console.log("".concat(P,"[Debug]: ").concat(e.join(" ")))},e}(),x=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:p.Warn,loggerProvider:new R,optOut:!1,serverUrl:I,serverZone:"US",useBatch:!1}},U=function(){function e(e){var t,n,i,r;this._optOut=!1;var o=x();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.optOut=null!==(i=e.optOut)&&void 0!==i?i:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(r=e.useBatch)&&void 0!==r?r:o.useBatch,this.loggerProvider.enable(this.logLevel);var s=N(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),D=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":I},N=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=x().serverZone),void 0===n&&(n=x().useBatch),e)return{serverUrl:e,serverZone:void 0};var i=["US","EU"].includes(t)?t:x().serverZone;return{serverZone:i,serverUrl:D(i,n)}};function q(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var A=function(){function e(){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduled=null,this.queue=[]}return e.prototype.setup=function(e){var t;return o(this,void 0,void 0,(function(){var n,i=this;return s(this,(function(r){switch(r.label){case 0:return this.config=e,this.storageKey="".concat(b,"_").concat(this.config.apiKey.substring(0,10)),[4,null===(t=this.config.storageProvider)||void 0===t?void 0:t.get(this.storageKey)];case 1:return n=r.sent(),this.saveEvents(),n&&n.length>0&&Promise.all(n.map((function(e){return i.execute(e)}))).catch(),[2,Promise.resolve(void 0)]}}))}))},e.prototype.execute=function(e){var t=this;return new Promise((function(n){var i={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.addToQueue(i)}))},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter((function(t){return t.attempts<e.config.flushMaxRetries?(t.attempts+=1,!0):(e.fulfillRequest([t],500,"Event rejected due to exceeded retry count"),!1)})).forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(e.config.flushIntervalMillis)})),this.saveEvents()},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),o(this,void 0,void 0,(function(){var t,n,i,r=this;return s(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),s=t,u=this.config.flushQueueSize,a=Math.max(u,1),i=s.reduce((function(e,t,n){var i=Math.floor(n/a);return e[i]||(e[i]=[]),e[i].push(t),e}),[]),[4,Promise.all(i.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}var s,u,a}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),o(this,void 0,void 0,(function(){var n,i,o,u,a;return s(this,(function(s){switch(s.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];n={api_key:this.config.apiKey,events:e.map((function(e){var t=e.event;return t.extra,r(t,["extra"])})),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString()},s.label=1;case 1:return s.trys.push([1,3,,4]),i=N(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,[4,this.config.transportProvider.send(i,n)];case 2:return null===(o=s.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(o,e),[3,4]):("body"in o?this.fulfillRequest(e,o.statusCode,"".concat(o.status,": ").concat(q(o))):this.fulfillRequest(e,o.statusCode,o.status),[2]);case 3:return u=s.sent(),a=(c=u)instanceof Error?c.message:String(c),this.config.loggerProvider.error(a),this.fulfillRequest(e,0,a),[3,4];case 4:return[2]}var c}))}))},e.prototype.handleResponse=function(e,t){var n=e.status;switch(n){case v.Success:this.handleSuccessResponse(e,t);break;case v.Invalid:this.handleInvalidResponse(e,t);break;case v.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case v.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(n,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var i=c(c(c(c([],a(Object.values(e.body.eventsWithInvalidFields)),!1),a(Object.values(e.body.eventsWithMissingFields)),!1),a(Object.values(e.body.eventsWithInvalidIdLengths)),!1),a(e.body.silencedEvents),!1).flat(),r=new Set(i),o=t.filter((function(t,i){if(!r.has(i))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));o.length>0&&this.config.loggerProvider.warn(q(e)),this.addToQueue.apply(this,c([],a(o),!1))}},e.prototype.handlePayloadTooLargeResponse=function(e,t){1!==t.length?(this.config.loggerProvider.warn(q(e)),this.config.flushQueueSize/=2,this.addToQueue.apply(this,c([],a(t),!1))):this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,i=Object.keys(e.body.exceededDailyQuotaUsers),r=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(i),u=new Set(r),l=new Set(o),d=t.filter((function(t,i){if(!(t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&u.has(t.event.device_id)))return l.has(i)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));d.length>0&&this.config.loggerProvider.warn(q(e)),this.addToQueue.apply(this,c([],a(d),!1))},e.prototype.handleOtherResponse=function(e){var t=this;this.addToQueue.apply(this,c([],a(e.map((function(e){return e.timeout=e.attempts*t.retryTimeout,e}))),!1))},e.prototype.fulfillRequest=function(e,t,n){this.saveEvents(),e.forEach((function(e){return e.callback(h(e.event,t,n))}))},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=Array.from(this.queue.map((function(e){return e.event})));this.config.storageProvider.set(this.storageKey,e)}},e}(),L=function(e){return function(){var t=i({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},j=function(e,t){var n,i;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var r=u(t.split(".")),o=r.next();!o.done;o=r.next()){var s=o.value;if(!(s in e))return;e=e[s]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}return e},C=function(e,t){return function(){var n,i,r={};try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;r[a]=j(e,a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r}},M=function(e,t,n,i,r){return void 0===r&&(r=null),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var u=n(),a=u.logger,c=u.logLevel;if(c&&c<p.Debug||!c||!a)return e.apply(r,o);var l,d={type:"invoke public method",name:t,args:o,stacktrace:(l=1,void 0===l&&(l=0),((new Error).stack||"").split("\n").slice(2+l).map((function(e){return e.trim()}))),time:{start:(new Date).toISOString()},states:{}};i&&d.states&&(d.states.before=i());var f=e.apply(r,o);return f&&f.promise?f.promise.then((function(){i&&d.states&&(d.states.after=i()),d.time&&(d.time.end=(new Date).toISOString()),a.debug(JSON.stringify(d,null,2))})):(i&&d.states&&(d.states.after=i()),d.time&&(d.time.end=(new Date).toISOString()),a.debug(JSON.stringify(d,null,2))),f}},V=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){return[2,!0]}))}))},e.prototype.get=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.memoryStorage.get(e)]}))}))},e.prototype.getRaw=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}}))}))},e.prototype.set=function(e,t){return o(this,void 0,void 0,(function(){return s(this,(function(n){return this.memoryStorage.set(e,t),[2]}))}))},e.prototype.remove=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return this.memoryStorage.delete(e),[2]}))}))},e.prototype.reset=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){return this.memoryStorage.clear(),[2]}))}))},e}(),F=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,i,r,o,s,u,a,c,l,d,f,p,h,g,y,m,b,I,_,w,S;if("object"!=typeof e)return null;var E=e.code||0,T=this.buildStatus(E);switch(T){case v.Success:return{status:T,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(i=e.server_upload_time)&&void 0!==i?i:0}};case v.Invalid:return{status:T,statusCode:E,body:{error:null!==(r=e.error)&&void 0!==r?r:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(u=e.events_with_missing_fields)&&void 0!==u?u:{},eventsWithInvalidIdLengths:null!==(a=e.events_with_invalid_id_lengths)&&void 0!==a?a:{},epsThreshold:null!==(c=e.eps_threshold)&&void 0!==c?c:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(p=e.throttled_devices)&&void 0!==p?p:{},throttledEvents:null!==(h=e.throttled_events)&&void 0!==h?h:[]}};case v.PayloadTooLarge:return{status:T,statusCode:E,body:{error:null!==(g=e.error)&&void 0!==g?g:""}};case v.RateLimit:return{status:T,statusCode:E,body:{error:null!==(y=e.error)&&void 0!==y?y:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(b=e.throttled_devices)&&void 0!==b?b:{},throttledUsers:null!==(I=e.throttled_users)&&void 0!==I?I:{},exceededDailyQuotaDevices:null!==(_=e.exceeded_daily_quota_devices)&&void 0!==_?_:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(S=e.throttled_events)&&void 0!==S?S:[]}};case v.Timeout:default:return{status:T,statusCode:E}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?v.Success:429===e?v.RateLimit:413===e?v.PayloadTooLarge:408===e?v.Timeout:e>=400&&e<500?v.Invalid:e>=500?v.Failed:v.Unknown},e}(),Q=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},$=function(){var e,t=Q();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),i=K(n[0]),r=K(n[1]);return r?(e[i]=r,e):e}),{}):{}},K=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},B="dclid",z="fbclid",W="gbraid",J="gclid",Y="ko_click_id",Z="li_fat_id",G="msclkid",H="rtd_cid",X="ttclid",ee="twclid",te="wbraid",ne={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rtd_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},ie=function(){function e(){}return e.prototype.parse=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){return[2,i(i(i(i({},ne),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=$();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=$();return(e={})[B]=t[B],e[z]=t[z],e[W]=t[W],e[J]=t[J],e[Y]=t[Y],e[Z]=t[Z],e[G]=t[G],e[H]=t[H],e[X]=t[X],e[ee]=t[ee],e[te]=t[te],e},e}(),re=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[m,t,e.substring(0,n)].filter(Boolean).join("_")},oe=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},se=function(){function e(e){this.options=i({},e)}return e.prototype.isEnabled=function(){return o(this,void 0,void 0,(function(){var t,n;return s(this,(function(i){switch(i.label){case 0:if(!Q())return[2,!1];e.testValue=String(Date.now()),t=new e(this.options),n="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,t.set(n,e.testValue)];case 2:return i.sent(),[4,t.get(n)];case 3:return[2,i.sent()===e.testValue];case 4:return i.sent(),[2,!1];case 5:return[4,t.remove(n)];case 6:return i.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:if(!(t=n.sent()))return[2,void 0];try{try{t=decodeURIComponent(atob(t))}catch(e){}return[2,JSON.parse(t)]}catch(e){return[2,void 0]}return[2]}}))}))},e.prototype.getRaw=function(e){var t,n;return o(this,void 0,void 0,(function(){var i,r,o;return s(this,(function(s){return i=Q(),r=null!==(n=null===(t=null==i?void 0:i.document)||void 0===t?void 0:t.cookie.split("; "))&&void 0!==n?n:[],(o=r.find((function(t){return 0===t.indexOf(e+"=")})))?[2,o.substring(e.length+1)]:[2,void 0]}))}))},e.prototype.set=function(e,t){var n;return o(this,void 0,void 0,(function(){var i,r,o,u,a,c;return s(this,(function(s){try{i=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,o=void 0,(r=null!==t?i:-1)&&((u=new Date).setTime(u.getTime()+24*r*60*60*1e3),o=u),a="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t)))),o&&(a+="; expires=".concat(o.toUTCString())),a+="; path=/",this.options.domain&&(a+="; domain=".concat(this.options.domain)),this.options.secure&&(a+="; Secure"),this.options.sameSite&&(a+="; SameSite=".concat(this.options.sameSite)),(c=Q())&&(c.document.cookie=a)}catch(e){}return[2]}))}))},e.prototype.remove=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.set(e,null)];case 1:return t.sent(),[2]}}))}))},e.prototype.reset=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),ue=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.send=function(e,t){return o(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,r.sent().json()];case 2:return i=r.sent(),[2,this.buildResponse(i)]}}))}))},t}(F),ae=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:ce(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),ce=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},le=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),de=function(){return de=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},de.apply(this,arguments)},fe=function(e,t){var n=typeof e;if(n!==typeof t)return!1;for(var i=0,r=["string","number","boolean","undefined"];i<r.length;i++){if(r[i]===n)return e===t}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var o=Array.isArray(e),s=Array.isArray(t);if(o!==s)return!1;if(!o||!s){var u=Object.keys(e).sort(),a=Object.keys(t).sort();if(!fe(u,a))return!1;var c=!0;return Object.keys(e).forEach((function(n){fe(e[n],t[n])||(c=!1)})),c}for(var l=0;l<e.length;l++)if(!fe(e[l],t[l]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i});var pe=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=de({},this.identity.userProperties),n=de(de({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){for(var t=n.userProperties||{},i=0,r=Object.entries(e);i<r.length;i++){var o=r[i],s=o[0],u=o[1];switch(s){case"$set":for(var a=0,c=Object.entries(u);a<c.length;a++){var l=c[a],d=l[0],f=l[1];t[d]=f}break;case"$unset":for(var p=0,v=Object.keys(u);p<v.length;p++){delete t[d=v[p]]}break;case"$clearAll":t={}}}return n.userProperties=t,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return de({},this.identity)},e.prototype.setIdentity=function(e){var t=de({},this.identity);this.identity=de({},e),fe(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),ve="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,he=function(){function e(){this.identityStore=new pe,this.eventBridge=new le,this.applicationContextProvider=new ae}return e.getInstance=function(t){return ve.analyticsConnectorInstances||(ve.analyticsConnectorInstances={}),ve.analyticsConnectorInstances[t]||(ve.analyticsConnectorInstances[t]=new e),ve.analyticsConnectorInstances[t]},e}(),ge=function(e){return void 0===e&&(e="$default_instance"),he.getInstance(e)},ye=function(){function e(){this.name="identity",this.type="before",this.identityStore=ge().identityStore}return e.prototype.execute=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]}))}))},e.prototype.setup=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return e.instanceName&&(this.identityStore=ge(e.instanceName).identityStore),[2]}))}))},e}(),me=function(){var e,t,n,i;if("undefined"==typeof navigator)return"";var r=navigator.userLanguage;return null!==(i=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:r)&&void 0!==i?i:""},be=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])},Ie=function(e){return be(e,"attribution")},_e=function(e){var t,n,i=function(){return!1},r=void 0;return(n=e.defaultTracking,be(n,"pageViews"))&&(i=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(i=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:i,trackHistoryChanges:r,eventType:t}},we=function(e,t){for(var n=0;n<t.length;n++){var i=t[n],r=i.name,o=i.args,s=i.resolve,u=e&&e[r];if("function"==typeof u){var a=u.apply(e,o);"function"==typeof s&&s(null==a?void 0:a.promise)}}return e},Se=function(e){return e&&void 0!==e._q},Ee=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="amplitude-ts/".concat("2.3.3"),"undefined"!=typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){var t,n;return o(this,void 0,void 0,(function(){var r,o,u;return s(this,(function(s){return r=(new Date).getTime(),o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1,u=null!==(n=e.event_id)&&void 0!==n?n:o+1,this.config.lastEventId=u,e.time||(this.config.lastEventTime=r),[2,i(i(i(i(i(i(i(i({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:me()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:g(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:u,library:this.library,user_agent:this.userAgent})]}))}))},e}(),Te=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return o(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(r){switch(r.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),i="AMP_TEST",r.label=1;case 1:return r.trys.push([1,4,5,7]),[4,n.set(i,t)];case 2:return r.sent(),[4,n.get(i)];case 3:return[2,r.sent()===t];case 4:return r.sent(),[2,!1];case 5:return[4,n.remove(i)];case 6:return r.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return(t=n.sent())?[2,JSON.parse(t)]:[2,void 0];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}}))}))},e.prototype.getRaw=function(e){var t;return o(this,void 0,void 0,(function(){return s(this,(function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]}))}))},e.prototype.set=function(e,t){var n;return o(this,void 0,void 0,(function(){return s(this,(function(i){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]}))}))},e.prototype.remove=function(e){var t;return o(this,void 0,void 0,(function(){return s(this,(function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]}))}))},e.prototype.reset=function(){var e;return o(this,void 0,void 0,(function(){return s(this,(function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]}))}))},e}(),Oe=1e3,ke=function(e){function t(t){var n,i=this;return(i=e.call(this,null===(n=Q())||void 0===n?void 0:n.localStorage)||this).loggerProvider=null==t?void 0:t.loggerProvider,i}return n(t,e),t.prototype.set=function(t,n){var i;return o(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>Oe?(r=n.length-Oe,[4,e.prototype.set.call(this,t,n.slice(0,Oe))]):[3,2];case 1:return o.sent(),null===(i=this.loggerProvider)||void 0===i||i.error("Failed to save ".concat(r," events because the queue length exceeded ").concat(Oe,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))},t}(Te),Pe=function(e){function t(){var t;return e.call(this,null===(t=Q())||void 0===t?void 0:t.sessionStorage)||this}return n(t,e),t}(Te),Re=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={done:4},t}return n(t,e),t.prototype.send=function(e,t){return o(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return[2,new Promise((function(i,r){"undefined"==typeof XMLHttpRequest&&r(new Error("XHRTransport is not supported."));var o=new XMLHttpRequest;o.open("POST",e,!0),o.onreadystatechange=function(){if(o.readyState===n.state.done)try{var e=o.responseText,t=JSON.parse(e),s=n.buildResponse(t);i(s)}catch(e){r(e)}},o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Accept","*/*"),o.send(JSON.stringify(t))}))]}))}))},t}(F),xe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.send=function(e,t){return o(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return[2,new Promise((function(i,r){var o=Q();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var s=JSON.stringify(t);return i(o.navigator.sendBeacon(e,JSON.stringify(t))?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:s.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){r(e)}}))]}))}))},t}(F),Ue=function(e,t,n){return void 0===n&&(n=!0),o(void 0,void 0,void 0,(function(){var i,r,o,u,c,l,d,f,p;return s(this,(function(s){switch(s.label){case 0:return i=function(e){return"".concat(m.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(i)];case 1:return(r=s.sent())?n?[4,t.remove(i)]:[3,3]:[2,{optOut:!1}];case 2:s.sent(),s.label=3;case 3:return o=a(r.split("."),6),u=o[0],c=o[1],l=o[2],d=o[3],f=o[4],p=o[5],[2,{deviceId:u,userId:Ne(c),sessionId:De(d),lastEventId:De(p),lastEventTime:De(f),optOut:Boolean(l)}]}}))}))},De=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},Ne=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},qe="[Amplitude]",Ae="".concat(qe," Form Started"),Le="".concat(qe," Form Submitted"),je="".concat(qe," File Downloaded"),Ce="session_start",Me="session_end",Ve="".concat(qe," File Extension"),Fe="".concat(qe," File Name"),Qe="".concat(qe," Link ID"),$e="".concat(qe," Link Text"),Ke="".concat(qe," Link URL"),Be="".concat(qe," Form ID"),ze="".concat(qe," Form Name"),We="".concat(qe," Form Destination"),Je="cookie",Ye=function(e){function t(t,n,i,r,o,s,u,a,c,l,d,f,v,h,g,y,m,b,I,_,w,S,E,T,O,k,P,x,U){void 0===i&&(i=new V),void 0===r&&(r={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===u&&(u=1e3),void 0===a&&(a=5),void 0===c&&(c=30),void 0===l&&(l=Je),void 0===g&&(g=new R),void 0===y&&(y=p.Warn),void 0===b&&(b=!1),void 0===w&&(w=""),void 0===S&&(S="US"),void 0===T&&(T=18e5),void 0===O&&(O=new ke({loggerProvider:g})),void 0===k&&(k={ipAddress:!0,language:!0,platform:!0}),void 0===P&&(P="fetch"),void 0===x&&(x=!1);var D=e.call(this,{apiKey:t,storageProvider:O,transportProvider:He(P)})||this;return D.apiKey=t,D.appVersion=n,D.cookieOptions=r,D.defaultTracking=o,D.flushIntervalMillis=u,D.flushMaxRetries=a,D.flushQueueSize=c,D.identityStorage=l,D.ingestionMetadata=d,D.instanceName=f,D.loggerProvider=g,D.logLevel=y,D.minIdLength=m,D.partnerId=I,D.plan=_,D.serverUrl=w,D.serverZone=S,D.sessionTimeout=T,D.storageProvider=O,D.trackingOptions=k,D.transport=P,D.useBatch=x,D._optOut=!1,D._cookieStorage=i,D.deviceId=s,D.lastEventId=v,D.lastEventTime=h,D.optOut=b,D.sessionId=E,D.userId=U,D.loggerProvider.enable(D.logLevel),D}return n(t,e),Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),t.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId};this.cookieStorage.set(re(this.apiKey),e)},t}(U),Ze=function(e,t,n){return void 0===t&&(t={}),o(void 0,void 0,void 0,(function(){var r,o,u,a,c,l,d,f,p,v,h,y,m,b,I,_,w,S,E,T,O,k,P,R,x,U,D,N,q,A,L,j,C,M,V,F,Q,K,B;return s(this,(function(s){switch(s.label){case 0:return r=t.identityStorage||Je,_={},r===Je?[3,1]:(u="",[3,5]);case 1:return null===(S=null===(w=t.cookieOptions)||void 0===w?void 0:w.domain)||void 0===S?[3,2]:(a=S,[3,4]);case 2:return[4,Xe()];case 3:a=s.sent(),s.label=4;case 4:u=a,s.label=5;case 5:return o=i.apply(void 0,[(_.domain=u,_.expiration=365,_.sameSite="Lax",_.secure=!1,_.upgrade=!0,_),t.cookieOptions]),c=Ge(t.identityStorage,o),[4,Ue(e,c,null===(T=null===(E=t.cookieOptions)||void 0===E?void 0:E.upgrade)||void 0===T||T)];case 6:return l=s.sent(),[4,c.get(re(e))];case 7:return d=s.sent(),f=$(),p=null!==(R=null!==(P=null!==(k=null!==(O=t.deviceId)&&void 0!==O?O:f.deviceId)&&void 0!==k?k:null==d?void 0:d.deviceId)&&void 0!==P?P:l.deviceId)&&void 0!==R?R:g(),v=null!==(x=null==d?void 0:d.lastEventId)&&void 0!==x?x:l.lastEventId,h=null!==(U=null==d?void 0:d.lastEventTime)&&void 0!==U?U:l.lastEventTime,y=null!==(N=null!==(D=t.optOut)&&void 0!==D?D:null==d?void 0:d.optOut)&&void 0!==N?N:l.optOut,m=null!==(q=null==d?void 0:d.sessionId)&&void 0!==q?q:l.sessionId,b=null!==(L=null!==(A=t.userId)&&void 0!==A?A:null==d?void 0:d.userId)&&void 0!==L?L:l.userId,n.previousSessionDeviceId=null!==(j=null==d?void 0:d.deviceId)&&void 0!==j?j:l.deviceId,n.previousSessionUserId=null!==(C=null==d?void 0:d.userId)&&void 0!==C?C:l.userId,I={ipAddress:null===(V=null===(M=t.trackingOptions)||void 0===M?void 0:M.ipAddress)||void 0===V||V,language:null===(Q=null===(F=t.trackingOptions)||void 0===F?void 0:F.language)||void 0===Q||Q,platform:null===(B=null===(K=t.trackingOptions)||void 0===K?void 0:K.platform)||void 0===B||B},[2,new Ye(e,t.appVersion,c,o,t.defaultTracking,p,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,r,t.ingestionMetadata,t.instanceName,v,h,t.loggerProvider,t.logLevel,t.minIdLength,y,t.partnerId,t.plan,t.serverUrl,t.serverZone,m,t.sessionTimeout,t.storageProvider,I,t.transport,t.useBatch,b)]}}))}))},Ge=function(e,t){switch(void 0===e&&(e=Je),void 0===t&&(t={}),e){case"localStorage":return new ke;case"sessionStorage":return new Pe;case"none":return new V;default:return new se(i(i({},t),{expirationDays:t.expiration}))}},He=function(e){return"xhr"===e?new Re:"beacon"===e?new xe:new ue},Xe=function(e){return o(void 0,void 0,void 0,(function(){var t,n,i,r,o,u,a;return s(this,(function(s){switch(s.label){case 0:return[4,(new se).isEnabled()];case 1:if(!s.sent()||!e&&"undefined"==typeof location)return[2,""];for(t=null!=e?e:location.hostname,n=t.split("."),i=[],r="AMP_TLDTEST",o=n.length-2;o>=0;--o)i.push(n.slice(o).join("."));o=0,s.label=2;case 2:return o<i.length?(u=i[o],[4,(a=new se({domain:"."+u})).set(r,1)]):[3,7];case 3:return s.sent(),[4,a.get(r)];case 4:return s.sent()?[4,a.remove(r)]:[3,6];case 5:return s.sent(),[2,"."+u];case 6:return o++,[3,2];case 7:return[2,""]}}))}))},et=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},tt=function(e,t,n,i){void 0===i&&(i=!0),e.referrer;var o=e.referring_domain,s=r(e,["referrer","referring_domain"]),u=t||{};u.referrer;var a=u.referring_domain,c=r(u,["referrer","referring_domain"]);if(nt(n.excludeReferrers,e.referring_domain))return!1;if(!i&&function(e){return Object.values(e).every((function(e){return!e}))}(e)&&t)return!1;var l=JSON.stringify(s)!==JSON.stringify(c),d=et(o||"")!==et(a||"");return!t||l||d},nt=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))},it=function(e){var t=this;void 0===e&&(e={});var n={name:"@amplitude/plugin-web-attribution-browser",type:"before",setup:function(t,n){var r;return o(this,void 0,void 0,(function(){var o,u,c,l,d,f,p,v;return s(this,(function(s){switch(s.label){case 0:return o=i({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(b=null===(r=t.cookieOptions)||void 0===r?void 0:r.domain,I=b,I?(I.startsWith(".")&&(I=I.substring(1)),[new RegExp("".concat(I.replace(".","\\."),"$"))]):[])},e),t.loggerProvider.log("Installing @amplitude/plugin-web-attribution-browser."),u=t.cookieStorage,h=t.apiKey,void 0===(g="MKTG")&&(g=""),void 0===y&&(y=10),c=[m,g,h.substring(0,y)].filter(Boolean).join("_"),[4,Promise.all([(new ie).parse(),u.get(c)])];case 1:return l=a.apply(void 0,[s.sent(),2]),d=l[0],f=l[1],p=oe(t.sessionTimeout,t.lastEventTime),tt(d,f,o,p)&&(o.resetSessionOnNewCampaign&&(n.setSessionId(Date.now()),t.loggerProvider.log("Created a new session for new campaign.")),t.loggerProvider.log("Tracking attribution."),v=function(e,t){var n=i(i({},ne),e),r=Object.entries(n).reduce((function(e,n){var i,r=a(n,2),o=r[0],s=r[1];return e.setOnce("initial_".concat(o),null!==(i=null!=s?s:t.initialEmptyValue)&&void 0!==i?i:"EMPTY"),s?e.set(o,s):e.unset(o)}),new S);return E(r)}(d,o),n.track(v),u.set(c,d)),[2]}var h,g,y,b,I}))}))},execute:function(e){return o(t,void 0,void 0,(function(){return s(this,(function(t){return[2,e]}))}))}};return n},rt=function(e){var t={};for(var n in e){var i=e[n];i&&(t[n]=i)}return t},ot=function(e){var t;void 0===e&&(e={});var n,r=Q(),u=void 0,c=function(){return o(void 0,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return n={event_type:null!==(r=e.eventType)&&void 0!==r?r:"[Amplitude] Page Viewed"},t=[{}],[4,st()];case 1:return[2,(n.event_properties=i.apply(void 0,[i.apply(void 0,t.concat([o.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":"undefined"!=typeof location&&location.href||"","[Amplitude] Page Path":"undefined"!=typeof location&&location.pathname||"","[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":"undefined"!=typeof location&&location.href.split("?")[0]||""}]),n)]}}))}))},l=function(){return void 0===e.trackOn||"function"==typeof e.trackOn&&e.trackOn()},d="undefined"!=typeof location?location.href:null,f=function(){return o(void 0,void 0,void 0,(function(){var n,i,r,o;return s(this,(function(s){switch(s.label){case 0:return n=location.href,i=at(e.trackHistoryChanges,n,d||"")&&l(),d=n,i?(null==u||u.log("Tracking page view event"),null!=t?[3,1]:[3,3]):[3,4];case 1:return o=(r=t).track,[4,c()];case 2:o.apply(r,[s.sent()]),s.label=3;case 3:s.label=4;case 4:return[2]}}))}))},p=function(){f()},v={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,i){return o(void 0,void 0,void 0,(function(){var o,d;return s(this,(function(s){switch(s.label){case 0:return t=i,(u=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),r&&(r.addEventListener("popstate",p),n=r.history.pushState,r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var i=a(n,3),r=i[0],o=i[1],s=i[2];e.apply(t,[r,o,s]),f()}})),l()?(u.log("Tracking page view event"),d=(o=t).track,[4,c()]):[3,2];case 1:d.apply(o,[s.sent()]),s.label=2;case 2:return[2]}}))}))},execute:function(t){return o(void 0,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return"attribution"===e.trackOn&&ut(t)?(null==u||u.log("Enriching campaign event to page view event with campaign parameters"),[4,c()]):[3,2];case 1:n=r.sent(),t.event_type=n.event_type,t.event_properties=i(i({},t.event_properties),n.event_properties),r.label=2;case 2:return[2,t]}}))}))},teardown:function(){return o(void 0,void 0,void 0,(function(){return s(this,(function(e){return r&&(r.removeEventListener("popstate",p),n&&(r.history.pushState=n)),[2]}))}))}};return v},st=function(){return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=rt,[4,(new ie).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},ut=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[l.SET]||{},i=t[l.UNSET]||{},r=c(c([],a(Object.keys(n)),!1),a(Object.keys(i)),!1);return Object.keys(ne).every((function(e){return r.includes(e)}))}return!1},at=function(e,t,n){return"pathOnly"===e?t.split("?")[0]!==n.split("?")[0]:t!==n},ct=function(){var e,t=[],n=function(e,n,i){e.addEventListener(n,i),t.push({element:e,type:n,handler:i})};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(t,i){return o(void 0,void 0,void 0,(function(){var r;return s(this,(function(o){return i?("undefined"==typeof document||(r=function(e){var t=!1;n(e,"change",(function(){var n;t||i.track(Ae,((n={})[Be]=e.id,n[ze]=lt(e.name),n[We]=e.action,n)),t=!0})),n(e,"submit",(function(){var n,r;t||i.track(Ae,((n={})[Be]=e.id,n[ze]=lt(e.name),n[We]=e.action,n)),i.track(Le,((r={})[Be]=e.id,r[ze]=lt(e.name),r[We]=e.action,r)),t=!1}))},Array.from(document.getElementsByTagName("form")).forEach(r),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"FORM"===e.nodeName&&r(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(r)}))}))}))).observe(document.body,{subtree:!0,childList:!0})),[2]):(t.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked."),[2])}))}))},execute:function(e){return o(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,e]}))}))},teardown:function(){return o(void 0,void 0,void 0,(function(){return s(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,i=e.handler;null==t||t.removeEventListener(n,i)})),t=[],[2]}))}))}}},lt=function(e){if("string"==typeof e)return e},dt=function(){var e,t=[];return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(n,i){return o(void 0,void 0,void 0,(function(){var r,o;return s(this,(function(s){return i?("undefined"==typeof document||(r=function(e){var n;try{n=new URL(e.href,window.location.href)}catch(e){return}var r=o.exec(n.href),s=null==r?void 0:r[1];s&&function(e,n,i){e.addEventListener(n,i),t.push({element:e,type:n,handler:i})}(e,"click",(function(){var t;s&&i.track(je,((t={})[Ve]=s,t[Fe]=n.pathname,t[Qe]=e.id,t[$e]=e.text,t[Ke]=e.href,t))}))},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)$/,Array.from(document.getElementsByTagName("a")).forEach(r),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"A"===e.nodeName&&r(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(r)}))}))}))).observe(document.body,{subtree:!0,childList:!0})),[2]):(n.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked."),[2])}))}))},execute:function(e){return o(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,e]}))}))},teardown:function(){return o(void 0,void 0,void 0,(function(){return s(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,i=e.handler;null==t||t.removeEventListener(n,i)})),t=[],[2]}))}))}}},ft=!1,pt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.init=function(e,t,n){var r,o;return void 0===e&&(e=""),arguments.length>2?(r=t,o=n):"string"==typeof t?(r=t,o=void 0):(r=null==t?void 0:t.userId,o=t),T(this._init(i(i({},o),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r;return o(this,void 0,void 0,(function(){var o,u,a,c,l=this;return s(this,(function(s){switch(s.label){case 0:return this.initializing?[2]:(this.initializing=!0,[4,Ze(t.apiKey,t,this)]);case 1:return o=s.sent(),[4,e.prototype._init.call(this,o)];case 2:return s.sent(),this.setSessionId(null!==(r=null!==(n=t.sessionId)&&void 0!==n?n:this.config.sessionId)&&void 0!==r?r:Date.now()),(u=ge(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),[4,this.add(new A).promise];case 3:return s.sent(),[4,this.add(new Ee).promise];case 4:return s.sent(),[4,this.add(new ye).promise];case 5:return s.sent(),f=this.config,ft||void 0!==f.defaultTracking||(f.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),ft=!0),d=this.config.defaultTracking,be(d,"fileDownloads")?[4,this.add(dt()).promise]:[3,7];case 6:s.sent(),s.label=7;case 7:return function(e){return be(e,"formInteractions")}(this.config.defaultTracking)?[4,this.add(ct()).promise]:[3,9];case 8:s.sent(),s.label=9;case 9:return Ie(this.config.defaultTracking)?(a=function(e){return Ie(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.attribution&&"object"==typeof e.defaultTracking.attribution?i({},e.defaultTracking.attribution):{}}(this.config),c=it(a),[4,this.add(c).promise]):[3,11];case 10:s.sent(),s.label=11;case 11:return[4,this.add(ot(_e(this.config))).promise];case 12:return s.sent(),this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 13:return s.sent(),u.eventBridge.setEventReceiver((function(e){l.track(e.eventType,e.eventProperties)})),[2]}var d,f}))}))},t.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},t.prototype.setUserId=function(e){this.config?e===this.config.userId&&void 0!==e||(this.config.userId=e,function(e,t){ge(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName)):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},t.prototype.setDeviceId=function(e){this.config?(this.config.deviceId=e,function(e,t){ge(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName)):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(g()),this.setUserId(void 0)},t.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t;if(this.config){if(e!==this.config.sessionId){var n,i=this.getSessionId(),r=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,n=this.config.defaultTracking,be(n,"sessions")&&(i&&r&&this.track(Me,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:i,time:r+1,user_id:this.previousSessionUserId}),this.config.lastEventTime=this.config.sessionId,this.track(Ce,void 0,{event_id:++o,session_id:this.config.sessionId,time:this.config.lastEventTime})),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId}}else this.q.push(this.setSessionId.bind(this,e))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=He(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(Se(t)){var i=t._q;t._q=[],t=we(new S,i)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},t.prototype.groupIdentify=function(t,n,i,r){if(Se(i)){var o=i._q;i._q=[],i=we(new S,o)}return e.prototype.groupIdentify.call(this,t,n,i,r)},t.prototype.revenue=function(t,n){if(Se(t)){var i=t._q;t._q=[],t=we(new k,i)}return e.prototype.revenue.call(this,t,n)},t.prototype.process=function(t){return o(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){return n=Date.now(),i=oe(this.config.sessionTimeout,this.config.lastEventTime),t.event_type===Ce||t.event_type===Me||t.session_id&&t.session_id!==this.getSessionId()||!i||this.setSessionId(n),[2,e.prototype.process.call(this,t)]}))}))},t}(O),vt=function(){var e=new pt;return{init:M(e.init.bind(e),"init",L(e),C(e,["config"])),add:M(e.add.bind(e),"add",L(e),C(e,["config.apiKey","timeline.plugins"])),remove:M(e.remove.bind(e),"remove",L(e),C(e,["config.apiKey","timeline.plugins"])),track:M(e.track.bind(e),"track",L(e),C(e,["config.apiKey","timeline.queue.length"])),logEvent:M(e.logEvent.bind(e),"logEvent",L(e),C(e,["config.apiKey","timeline.queue.length"])),identify:M(e.identify.bind(e),"identify",L(e),C(e,["config.apiKey","timeline.queue.length"])),groupIdentify:M(e.groupIdentify.bind(e),"groupIdentify",L(e),C(e,["config.apiKey","timeline.queue.length"])),setGroup:M(e.setGroup.bind(e),"setGroup",L(e),C(e,["config.apiKey","timeline.queue.length"])),revenue:M(e.revenue.bind(e),"revenue",L(e),C(e,["config.apiKey","timeline.queue.length"])),flush:M(e.flush.bind(e),"flush",L(e),C(e,["config.apiKey","timeline.queue.length"])),getUserId:M(e.getUserId.bind(e),"getUserId",L(e),C(e,["config","config.userId"])),setUserId:M(e.setUserId.bind(e),"setUserId",L(e),C(e,["config","config.userId"])),getDeviceId:M(e.getDeviceId.bind(e),"getDeviceId",L(e),C(e,["config","config.deviceId"])),setDeviceId:M(e.setDeviceId.bind(e),"setDeviceId",L(e),C(e,["config","config.deviceId"])),reset:M(e.reset.bind(e),"reset",L(e),C(e,["config","config.userId","config.deviceId"])),getSessionId:M(e.getSessionId.bind(e),"getSessionId",L(e),C(e,["config"])),setSessionId:M(e.setSessionId.bind(e),"setSessionId",L(e),C(e,["config"])),extendSession:M(e.extendSession.bind(e),"extendSession",L(e),C(e,["config"])),setOptOut:M(e.setOptOut.bind(e),"setOptOut",L(e),C(e,["config"])),setTransport:M(e.setTransport.bind(e),"setTransport",L(e),C(e,["config"]))}}();vt.add,vt.extendSession,vt.flush,vt.getDeviceId,vt.getSessionId,vt.getUserId,vt.groupIdentify,vt.identify;var ht=vt.init;vt.logEvent,vt.remove,vt.reset,vt.revenue,vt.setDeviceId,vt.setGroup,vt.setOptOut,vt.setSessionId,vt.setTransport,vt.setUserId;var gt=vt.track;let yt;const mt=new Uint8Array(16);function bt(){if(!yt&&(yt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!yt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yt(mt)}const It=[];for(let e=0;e<256;++e)It.push((e+256).toString(16).slice(1));var _t={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};e.initializeImpl=function(){ht("6b4a3fc5591b12f8187aab3be4db2002")},e.trackEventImpl=function(e,t){gt(e,t)},e.uuidv4=function(e,t,n){if(_t.randomUUID&&!t&&!e)return _t.randomUUID();const i=(e=e||{}).random||(e.rng||bt)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=i[e];return t}return function(e,t=0){return It[e[t+0]]+It[e[t+1]]+It[e[t+2]]+It[e[t+3]]+"-"+It[e[t+4]]+It[e[t+5]]+"-"+It[e[t+6]]+It[e[t+7]]+"-"+It[e[t+8]]+It[e[t+9]]+"-"+It[e[t+10]]+It[e[t+11]]+It[e[t+12]]+It[e[t+13]]+It[e[t+14]]+It[e[t+15]]}(i)}}));
@@ -1 +1 @@
1
- function e(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{d(o.next(e))}catch(e){r(e)}}function a(e){try{d(o.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}d((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const t=[1e3,2e3,4e3],n=t.length;function o(i,r=0){return e(this,void 0,void 0,(function*(){try{return yield i()}catch(e){if(r>=n)throw e;return yield new Promise((e=>setTimeout(e,t[r]))),o(i,r+1)}}))}let i;const r=()=>i,s=()=>{const t=document.createElement("div"),n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.zIndex="1",n.display="none";const o=window.ShopAR__DeepAR;let i,r;let s;let a=!0;return{domElement:t,init:()=>e(void 0,void 0,void 0,(function*(){return null==r&&(r=e(void 0,void 0,void 0,(function*(){i=yield o.deepar.initialize({licenseKey:"your_license_key_goes_here",previewElement:t,additionalOptions:{hint:"rigidFaceTrackingInit"}})}))),r})),parse:t=>e(void 0,void 0,void 0,(function*(){return null==s&&(s=i.switchEffect(t)),s})),isPaused:()=>a,resume:()=>{a=!1,i.setPaused(a),n.display=""},pause:()=>{a=!0,i.setPaused(a),n.display="none"}}};let a;const d=()=>a,c=()=>{const t=document.createElement("canvas"),n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.zIndex="1";const o=window.ShopAR__THREE,i=o.THREE,r=new i.WebGLRenderer({canvas:t,antialias:!0});r.outputEncoding=i.sRGBEncoding,r.toneMapping=i.LinearToneMapping,r.toneMappingExposure=Math.pow(1.2,5),r.setPixelRatio(2*window.devicePixelRatio),r.setClearColor(new i.Color(16777215)),r.useLegacyLights=!1;const s=new i.PerspectiveCamera(60,1,2,100);s.position.set(8,6,14);const a=new i.Scene,d=new o.OrbitControls(s,r.domElement);d.target.set(0,.03,0),d.dampingFactor=.3;{const e=new i.AmbientLight(new i.Color(16777215),.3),t=new i.DirectionalLight(new i.Color(16777215),.1);t.position.set(10,0,10);const n=new i.DirectionalLight(new i.Color(16777215),.1);n.position.set(-10,0,10),a.add(e,t,n)}const c=()=>{const e=t.clientWidth,n=t.clientHeight;t.width===e&&t.height===n||(r.setSize(e,n,!1),s.aspect=e/n,s.updateProjectionMatrix())};let l;let u=!1;const p=()=>{u||(requestAnimationFrame(p),c(),d.update(),r.render(a,s))};return{domElement:t,updateSize:c,parse:(t,n)=>e(void 0,void 0,void 0,(function*(){return null==l&&(l=e(void 0,void 0,void 0,(function*(){const e=new o.RGBELoader,s=function(e,t){const n=e.THREE,o=new n.DataTexture(t.data,t.width,t.height,void 0,t.type,void 0,n.ClampToEdgeWrapping,n.ClampToEdgeWrapping,n.LinearFilter,n.LinearFilter,1,n.LinearEncoding);return o.flipY=!0,o.generateMipmaps=!1,o.needsUpdate=!0,o}(o,e.parse(n));s.mapping=i.EquirectangularReflectionMapping,s.encoding=i.LinearEncoding,a.environment=s;const d=(new o.GLTFLoader).setDRACOLoader((new o.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${i.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new o.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${i.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(r)).setMeshoptDecoder("function"==typeof o.MeshoptDecoder?o.MeshoptDecoder():o.MeshoptDecoder),c=yield d.parseAsync(t.buffer,"");a.add(c.scene),a.traverse((e=>{if(e instanceof i.Mesh){const t=e.material;t.depthWrite=!0,t instanceof i.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}))}))),l})),isPaused:()=>u,resume:()=>{u=!1,p(),n.display=""},pause:()=>{u=!0,n.display="none"}}};function l(e,t,n){const o=document.createElement("button");return o.id=e,o.type="button",o.className="shopar-btn",o.textContent=t,o.ariaLabel=n,o.style.zIndex="2",o}const u="0.0.2";let p=`https://cdn.jsdelivr.net/npm/shopar-plugin@${u}/dist`;const h={update:e=>{null!=e&&(p=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>p};function f(t){return e(this,void 0,void 0,(function*(){const n=yield o((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(t).catch((e=>{throw console.error(e),new Error("Resource unavailable.")}));if(!e.ok)throw new Error(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield n.blob()).arrayBuffer()}catch(e){throw console.error(e),new Error("Resource has invalid body.")}}))}function w(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}const v=[Uint8Array,Uint32Array],m=v.length-2,y=window.location.hostname.charCodeAt(m),g=y^y,E=new v[1]([g]);function b(t,n,i){return e(this,void 0,void 0,(function*(){let r="glb".charCodeAt(0),s="3d".charCodeAt(0);r>>=1,r+=s;const a=String.fromCharCode(r+14);s>>=2,r^=s+2;const d=String.fromCharCode(r-3);r^=5;const c=String.fromCharCode(r-7);r^=2;const l=String.fromCharCode(r-7),u=window[`${c}${d+a+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${l}`],p=yield o((()=>e(this,void 0,void 0,(function*(){const e=yield u(`${t}`).catch((()=>{throw new Error("Unknown error.")}));if(!e.ok)throw new Error("Unknown error.");return e})))),h=new v[0](yield(yield p.blob().catch((()=>{throw new Error("Unknown error.")}))).arrayBuffer().catch((()=>{throw new Error("Unknown error.")})));i+=s;const f=h.byteLength;if(E[g]=Math.min(76,n)*((r>>5)-1),152===E[g]&&(E[g]=f),i==g)return h;i=g,i^=g;for(let e=0,t=h.length;e<t;e++)E[g]^=E[i]<<13,E[g]^=E[i]>>17,E[g]^=E[i]<<5,h[e]=h[e]^E[g];return i^=E[0],i^=E[1],i^=E[2],h}))}function C(e,t){if(null==e)throw new Error(`'${t}' not specified.`)}function P(e,t){if("string"!=typeof e)throw new Error(`'${t}' must be a string.`)}function L(e){const{apiKey:t,sku:n,targetElement:o,baseUrl:i}=e;C(t,"apiKey"),P(t,"apiKey"),C(n,"sku"),P(n,"sku"),C(o,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new Error(`'${t}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&P(i,"baseUrl")}var R;!function(e){e[e.None=0]="None",e[e.AR=1]="AR",e[e.Preview=2]="Preview"}(R||(R={}));let A=R.None,S=0;const x=[];function $(){if(A===R.AR){const e=r();null==e||e.isPaused()||e.pause()}else if(A===R.Preview){const e=d();null==e||e.isPaused()||e.pause()}}function M(e){var t;A=e,x.forEach((e=>null==e?void 0:e.classList.remove("active"))),null===(t=x[A])||void 0===t||t.classList.add("active")}function k(t){return e(this,void 0,void 0,(function*(){L(t);const{apiKey:n,sku:r,targetElement:d}=t;h.update(t.baseUrl);const u=yield function(t,n){return e(this,void 0,void 0,(function*(){const i=yield o((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.spexx.ai/plugin?${new URLSearchParams({apiKey:t,sku:n})}`).catch((e=>{throw console.error(e),new Error("API unavailable.")}));if(!e.ok)throw new Error(`API call failed with status ${e.status}.`);return e}))));try{return yield i.json()}catch(e){throw console.error(e),new Error("API returned invalid body.")}}))}(n,r);!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new Error(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(d),d.style.position="relative";const p=function(){const e=document.createElement("div"),t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}();d.appendChild(p);const v=function(){const e=document.createElement("div");return e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e}();p.appendChild(v);const m=function(){const e=document.createElement("div"),t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="1",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const i=document.createElement("div");return i.textContent="Loading...",n.appendChild(i),{container:e,show:()=>{t.display=""},hide:()=>{t.display="none"}}}();p.appendChild(m.container);const{arUrl:y,previewUrl:g}=u;if(null!=y){const t=Promise.all([w(`${h}/shopar-deepar.js`),f(y)]);x[R.AR]=l("shopar-btn-vto","AR","Launch virtual try-on"),v.appendChild(x[R.AR]),x[R.AR].onclick=()=>e(this,void 0,void 0,(function*(){const e=++S,n=R.AR,o=A===n?R.None:n;if($(),M(o),A===R.None)return;m.show();const[,r]=yield t;if(S!==e)return;const a=(null==i&&(i=s()),i);p.contains(a.domElement)||p.appendChild(a.domElement),yield a.init(),S===e&&(yield a.parse(r),S===e&&(a.resume(),m.hide()))}))}if(null!=g){const t=255,n=Promise.all([w(`${h}/shopar-three.js`),b(g,(new Date).getTime()+t,Math.random()*t),f(`${h}/env/studio2.hdr`)]);x[R.Preview]=l("shopar-btn-3d","3D","Launch 3D preview"),v.appendChild(x[R.Preview]),x[R.Preview].onclick=()=>e(this,void 0,void 0,(function*(){const e=++S,t=R.Preview,o=A===t?R.None:t;if($(),M(o),A===R.None)return;m.show();const[,i,r]=yield n;if(S!==e)return;const s=(null==a&&(a=c()),a);p.contains(s.domElement)||(p.appendChild(s.domElement),s.updateSize()),yield s.parse(i,r),S===e&&(s.resume(),m.hide())}))}}))}const T={setup:function(t){return e(this,void 0,void 0,(function*(){!function(t,n){e(this,void 0,void 0,(function*(){try{yield n()}catch(e){throw e instanceof Error?new T.PluginError(`${t} failed: ${e.message}`):(console.error(e),new T.PluginError(`${t} failed.`))}}))}("setup",(()=>k(t)))}))},version:u,PluginError:class extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}};export{T as plugin};
1
+ function e(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const t=[Uint8Array,Uint32Array],n=t.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],r=window[o[i[i[n]]]][o[i[i[i.length-1]]]],s=r.charCodeAt(n),a=s^s,c=new t[1]([a]);function d(){const e=(new TextEncoder).encode(r),t=o.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[o[t[2]]](String.fromCodePoint(...e))}const l=[1e3,2e3,4e3],u=l.length;function h(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=u)throw e;return yield new Promise((e=>setTimeout(e,l[n]))),h(t,n+1)}}))}let p;const m=()=>p,f=e=>{let t=!1;const n=[];e.then((()=>{t=!0,n.forEach((e=>e()))}));const o=e=>{t?e():n.push(e)},i={organizationId:"Unknown",sku:"Unknown"};let r,s=0;function a(e,t={}){t=Object.assign(Object.assign(Object.assign({},t),i),{vtoTime:(performance.now()-s)/1e3,vtoSessionId:r}),o((()=>{const{trackEventImpl:n}=window.ShopAR__analytics;n(e,t)}))}return{init:function(e,t){i.organizationId=e||"Unknown",i.sku=t||"Unknown",s=performance.now(),o((()=>{const{initializeImpl:e,uuidv4:t}=window.ShopAR__analytics;e(),r=t()}))},initialized:()=>a("initialized"),vtoLaunched:()=>a("vto_launched"),vtoCameraAsked:()=>a("vto_camera_asked"),vtoCameraGranted:()=>a("vto_camera_granted"),vtoCameraDenied:e=>a("vto_camera_denied",{error:e}),vtoInitSuccess:()=>a("vto_init_success"),previewLaunched:()=>a("preview_launched"),previewInteracted:()=>a("preview_interacted")}};let w;const v=()=>w,g=()=>{const t=m(),n=document.createElement("div"),o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.zIndex="1",o.display="none";const i=window.ShopAR__DeepAR;let r,s;const a={Glasses:"rigidFaceTrackingInit",Shoes:"footInit",Watches:void 0},c={Glasses:"user",Shoes:"environment",Watches:"environment"};let d;let l=!0;return{domElement:n,init:(o,d)=>e(void 0,void 0,void 0,(function*(){const l=null!=d?a[d]:void 0,u=null!=d?c[d]:"user";return null==s&&(s=e(void 0,void 0,void 0,(function*(){r=yield i.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:n,additionalOptions:{hint:l,cameraConfig:{facingMode:u,cameraPermissionAsked:()=>{t.vtoCameraAsked()},cameraPermissionGranted:()=>{t.vtoCameraGranted()}}}}),t.vtoInitSuccess()}))),s})),parse:t=>e(void 0,void 0,void 0,(function*(){return null==d&&(d=r.switchEffect(t)),d})),isPaused:()=>l,resume:()=>{l=!1,r.setPaused(l),o.display=""},pause:()=>{l=!0,r.setPaused(l),o.display="none"}}};let y;const E=()=>y,C=()=>{const t=m(),n=document.createElement("canvas"),o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.zIndex="1";const i=window.ShopAR__THREE,r=i.THREE,s=new r.WebGLRenderer({canvas:n,antialias:!0});s.outputEncoding=r.sRGBEncoding,s.toneMapping=r.LinearToneMapping,s.toneMappingExposure=Math.pow(1.2,5),s.setPixelRatio(2*window.devicePixelRatio),s.setClearColor(new r.Color(16777215)),s.useLegacyLights=!1;const a=new r.PerspectiveCamera(60,1,2,100);a.position.set(8,6,14);const c=new r.Scene,d=new i.OrbitControls(a,s.domElement);d.target.set(0,.03,0),d.dampingFactor=.3;{const e=function(e,t){let n;return()=>{n||e(),clearTimeout(n),n=setTimeout((()=>{n=void 0}),t)}}((()=>t.previewInteracted()),200);d.addEventListener("end",e)}{const e=new r.AmbientLight(new r.Color(16777215),.3),t=new r.DirectionalLight(new r.Color(16777215),.1);t.position.set(10,0,10);const n=new r.DirectionalLight(new r.Color(16777215),.1);n.position.set(-10,0,10),c.add(e,t,n)}const l=()=>{const e=n.clientWidth,t=n.clientHeight;n.width===e&&n.height===t||(s.setSize(e,t,!1),a.aspect=e/t,a.updateProjectionMatrix())};let u;let h=!1;const p=()=>{h||(requestAnimationFrame(p),l(),d.update(),s.render(c,a))};return{domElement:n,updateSize:l,parse:(t,n)=>e(void 0,void 0,void 0,(function*(){return null==u&&(u=e(void 0,void 0,void 0,(function*(){const e=new i.RGBELoader,o=function(e,t){const n=e.THREE,o=new n.DataTexture(t.data,t.width,t.height,void 0,t.type,void 0,n.ClampToEdgeWrapping,n.ClampToEdgeWrapping,n.LinearFilter,n.LinearFilter,1,n.LinearEncoding);return o.flipY=!0,o.generateMipmaps=!1,o.needsUpdate=!0,o}(i,e.parse(n));o.mapping=r.EquirectangularReflectionMapping,o.encoding=r.LinearEncoding,c.environment=o;const a=(new i.GLTFLoader).setDRACOLoader((new i.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${r.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new i.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${r.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(s)).setMeshoptDecoder("function"==typeof i.MeshoptDecoder?i.MeshoptDecoder():i.MeshoptDecoder),d=yield a.parseAsync(t.buffer,"");c.add(d.scene),c.traverse((e=>{if(e instanceof r.Mesh){const t=e.material;t.depthWrite=!0,t instanceof r.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}))}))),u})),isPaused:()=>h,resume:()=>{h=!1,p(),o.display=""},pause:()=>{h=!0,o.display="none"}}},b="0.0.3";let A=`https://cdn.jsdelivr.net/npm/shopar-plugin@${b}/dist`;const P={update:e=>{null!=e&&(A=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>A};function S(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}function L(e,t,n,o){const i=document.createElement("button");if(i.id=e,i.type="button",i.className="shopar-btn",null!=o){const e=S("1.75rem",o);i.appendChild(e)}{const e=document.createElement("span");e.textContent=t,i.appendChild(e)}return i.ariaLabel=n,i.style.zIndex="2",i}function R(t){return e(this,void 0,void 0,(function*(){const n=yield h((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(t).catch((e=>{throw console.error(e),new Error("Resource unavailable.")}));if(!e.ok)throw new Error(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield n.blob()).arrayBuffer()}catch(e){throw console.error(e),new Error("Resource has invalid body.")}}))}function k(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}function $(n,o,i){return e(this,void 0,void 0,(function*(){let r="glb".charCodeAt(0),s="3d".charCodeAt(0);r>>=1,r+=s;const d=String.fromCharCode(r+14);s>>=2,r^=s+2;const l=String.fromCharCode(r-3);r^=5;const u=String.fromCharCode(r-7);r^=2;const p=String.fromCharCode(r-7),m=window[`${u}${l+d+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${p}`],f=yield h((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${n}`).catch((()=>{throw new Error("Unknown error.")}));if(!e.ok)throw new Error("Unknown error.");return e})))),w=new t[0](yield(yield f.blob().catch((()=>{throw new Error("Unknown error.")}))).arrayBuffer().catch((()=>{throw new Error("Unknown error.")})));i+=s;const v=w.byteLength;if(c[a]=Math.min(76,o)*((r>>5)-1),152===c[a]&&(c[a]=v),i==a)return w;i=a,i^=a;for(let e=0,t=w.length;e<t;e++)c[a]^=c[i]<<13,c[a]^=c[i]>>17,c[a]^=c[i]<<5,w[e]=w[e]^c[a];return i^=c[0],i^=c[1],i^=c[2],w}))}function x(e,t){if(null==e)throw new Error(`'${t}' not specified.`)}function I(e,t){if("string"!=typeof e)throw new Error(`'${t}' must be a string.`)}function _(e){const{apiKey:t,sku:n,targetElement:o,baseUrl:i}=e;x(t,"apiKey"),I(t,"apiKey"),x(n,"sku"),I(n,"sku"),x(o,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new Error(`'${t}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&I(i,"baseUrl")}var M;!function(e){e[e.None=0]="None",e[e.AR=1]="AR",e[e.Preview=2]="Preview"}(M||(M={}));let T,N=M.None,U=0;const D=[];let j;function z(){if(N===M.AR){const e=v();null==e||e.isPaused()||e.pause()}else if(N===M.Preview){const e=E();null==e||e.isPaused()||e.pause()}}function G(e){if(N=e,N===M.None){const e=D.filter((e=>null!=e));T.replaceChildren(...e)}else T.replaceChildren(j)}function O(t){return e(this,void 0,void 0,(function*(){_(t);const{apiKey:n,sku:o,targetElement:i}=t;P.update(t.baseUrl);const r=function(t,n){return e(this,void 0,void 0,(function*(){const o=yield h((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:t,sku:n,sid:d()})}`).catch((e=>{throw console.error(e),new Error("API unavailable.")}));if(!e.ok)throw new Error(`API call failed with status ${e.status}.`);return e}))));try{return yield o.json()}catch(e){throw console.error(e),new Error("API returned invalid body.")}}))}(n,o),s=(a=k(`${P}/shopar-analytics.js`),null==p&&(p=f(a)),p);var a;s.init(n,o),function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new Error(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(i),i.style.position="relative";const c=function(){const e=document.createElement("div"),t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}();i.appendChild(c),T=function(){const e=document.createElement("div");return e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e}(),c.appendChild(T),j=L("shopar-btn-close","Close","Close ShopAR view",`${P}/img/icons/close.svg`),j.onclick=()=>{l.hide(),u.hide(),z(),G(M.None)};const l=function(){const e=document.createElement("div"),t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="1",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const i=document.createElement("div");return i.className="shopar-spinner",n.appendChild(i),{container:e,show:()=>{t.display=""},hide:()=>{t.display="none"}}}();c.appendChild(l.container);const u=function(){const e=document.createElement("div"),t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="1",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const i=S("4rem",`${P}/img/icons/close.svg`);n.appendChild(i);const r=document.createElement("div");r.className="shopar-error-title",r.textContent="Camera Error",n.appendChild(r);const s=document.createElement("div");return s.className="shopar-error-body",s.textContent="Please refresh the page and allow the use of camera.",n.appendChild(s),{container:e,show:()=>{t.display=""},hide:()=>{t.display="none"}}}();c.appendChild(u.container);const{category:m,arUrl:v,arKey:E,previewUrl:b}=yield r;if(s.initialized(),null!=v){const t=Promise.all([k(`${P}/shopar-deepar.js`),R(v)]),n={Glasses:`${P}/img/icons/glasses.svg`,Shoes:`${P}/img/icons/shoe.svg`,Watches:`${P}/img/icons/watch.svg`},o=null!=m&&n[m]||n.Glasses;D[M.AR]=L("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",o),T.appendChild(D[M.AR]),D[M.AR].onclick=()=>e(this,void 0,void 0,(function*(){const e=++U,n=M.AR,o=N===n?M.None:n;if(z(),G(o),N===M.None)return;s.vtoLaunched(),u.hide(),l.show();const[,i]=yield t;if(U!==e)return;const r=(null==w&&(w=g()),w);c.contains(r.domElement)||c.appendChild(r.domElement);try{yield r.init(E,m)}catch(e){return s.vtoCameraDenied(e),l.hide(),void u.show()}U===e&&(yield r.parse(i),U===e&&(r.resume(),l.hide()))}))}if(null!=b){const t=255,n=Promise.all([k(`${P}/shopar-three.js`),$(b,(new Date).getTime()+t,Math.random()*t),R(`${P}/env/studio2.hdr`)]);D[M.Preview]=L("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${P}/img/icons/cube.svg`),T.appendChild(D[M.Preview]),D[M.Preview].onclick=()=>e(this,void 0,void 0,(function*(){const e=++U,t=M.Preview,o=N===t?M.None:t;if(z(),G(o),N===M.None)return;s.previewLaunched(),u.hide(),l.show();const[,i,r]=yield n;if(U!==e)return;const a=(null==y&&(y=C()),y);c.contains(a.domElement)||(c.appendChild(a.domElement),a.updateSize()),yield a.parse(i,r),U===e&&(a.resume(),l.hide())}))}}))}const K={setup:function(t){return e(this,void 0,void 0,(function*(){!function(t,n){e(this,void 0,void 0,(function*(){try{yield n()}catch(e){throw e instanceof Error?new K.PluginError(`${t} failed: ${e.message}`):(console.error(e),new K.PluginError(`${t} failed.`))}}))}("setup",(()=>O(t)))}))},version:b,PluginError:class extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}};export{K as plugin};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{d(o.next(e))}catch(e){r(e)}}function a(e){try{d(o.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}d((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n=[1e3,2e3,4e3],o=n.length;function i(e,r=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(r>=o)throw t;return yield new Promise((e=>setTimeout(e,n[r]))),i(e,r+1)}}))}let r;const s=()=>r,a=()=>{const e=document.createElement("div"),n=e.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.zIndex="1",n.display="none";const o=window.ShopAR__DeepAR;let i,r;let s;let a=!0;return{domElement:e,init:()=>t(void 0,void 0,void 0,(function*(){return null==r&&(r=t(void 0,void 0,void 0,(function*(){i=yield o.deepar.initialize({licenseKey:"your_license_key_goes_here",previewElement:e,additionalOptions:{hint:"rigidFaceTrackingInit"}})}))),r})),parse:e=>t(void 0,void 0,void 0,(function*(){return null==s&&(s=i.switchEffect(e)),s})),isPaused:()=>a,resume:()=>{a=!1,i.setPaused(a),n.display=""},pause:()=>{a=!0,i.setPaused(a),n.display="none"}}};let d;const c=()=>d,l=()=>{const e=document.createElement("canvas"),n=e.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.zIndex="1";const o=window.ShopAR__THREE,i=o.THREE,r=new i.WebGLRenderer({canvas:e,antialias:!0});r.outputEncoding=i.sRGBEncoding,r.toneMapping=i.LinearToneMapping,r.toneMappingExposure=Math.pow(1.2,5),r.setPixelRatio(2*window.devicePixelRatio),r.setClearColor(new i.Color(16777215)),r.useLegacyLights=!1;const s=new i.PerspectiveCamera(60,1,2,100);s.position.set(8,6,14);const a=new i.Scene,d=new o.OrbitControls(s,r.domElement);d.target.set(0,.03,0),d.dampingFactor=.3;{const e=new i.AmbientLight(new i.Color(16777215),.3),t=new i.DirectionalLight(new i.Color(16777215),.1);t.position.set(10,0,10);const n=new i.DirectionalLight(new i.Color(16777215),.1);n.position.set(-10,0,10),a.add(e,t,n)}const c=()=>{const t=e.clientWidth,n=e.clientHeight;e.width===t&&e.height===n||(r.setSize(t,n,!1),s.aspect=t/n,s.updateProjectionMatrix())};let l;let u=!1;const p=()=>{u||(requestAnimationFrame(p),c(),d.update(),r.render(a,s))};return{domElement:e,updateSize:c,parse:(e,n)=>t(void 0,void 0,void 0,(function*(){return null==l&&(l=t(void 0,void 0,void 0,(function*(){const t=new o.RGBELoader,s=function(e,t){const n=e.THREE,o=new n.DataTexture(t.data,t.width,t.height,void 0,t.type,void 0,n.ClampToEdgeWrapping,n.ClampToEdgeWrapping,n.LinearFilter,n.LinearFilter,1,n.LinearEncoding);return o.flipY=!0,o.generateMipmaps=!1,o.needsUpdate=!0,o}(o,t.parse(n));s.mapping=i.EquirectangularReflectionMapping,s.encoding=i.LinearEncoding,a.environment=s;const d=(new o.GLTFLoader).setDRACOLoader((new o.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${i.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new o.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${i.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(r)).setMeshoptDecoder("function"==typeof o.MeshoptDecoder?o.MeshoptDecoder():o.MeshoptDecoder),c=yield d.parseAsync(e.buffer,"");a.add(c.scene),a.traverse((e=>{if(e instanceof i.Mesh){const t=e.material;t.depthWrite=!0,t instanceof i.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}))}))),l})),isPaused:()=>u,resume:()=>{u=!1,p(),n.display=""},pause:()=>{u=!0,n.display="none"}}};function u(e,t,n){const o=document.createElement("button");return o.id=e,o.type="button",o.className="shopar-btn",o.textContent=t,o.ariaLabel=n,o.style.zIndex="2",o}const p="0.0.2";let h=`https://cdn.jsdelivr.net/npm/shopar-plugin@${p}/dist`;const f={update:e=>{null!=e&&(h=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>h};function w(e){return t(this,void 0,void 0,(function*(){const n=yield i((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new Error("Resource unavailable.")}));if(!t.ok)throw new Error(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield n.blob()).arrayBuffer()}catch(e){throw console.error(e),new Error("Resource has invalid body.")}}))}function m(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}const v=[Uint8Array,Uint32Array],y=v.length-2,g=window.location.hostname.charCodeAt(y),E=g^g,b=new v[1]([E]);function C(e,n,o){return t(this,void 0,void 0,(function*(){let r="glb".charCodeAt(0),s="3d".charCodeAt(0);r>>=1,r+=s;const a=String.fromCharCode(r+14);s>>=2,r^=s+2;const d=String.fromCharCode(r-3);r^=5;const c=String.fromCharCode(r-7);r^=2;const l=String.fromCharCode(r-7),u=window[`${c}${d+a+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${l}`],p=yield i((()=>t(this,void 0,void 0,(function*(){const t=yield u(`${e}`).catch((()=>{throw new Error("Unknown error.")}));if(!t.ok)throw new Error("Unknown error.");return t})))),h=new v[0](yield(yield p.blob().catch((()=>{throw new Error("Unknown error.")}))).arrayBuffer().catch((()=>{throw new Error("Unknown error.")})));o+=s;const f=h.byteLength;if(b[E]=Math.min(76,n)*((r>>5)-1),152===b[E]&&(b[E]=f),o==E)return h;o=E,o^=E;for(let e=0,t=h.length;e<t;e++)b[E]^=b[o]<<13,b[E]^=b[o]>>17,b[E]^=b[o]<<5,h[e]=h[e]^b[E];return o^=b[0],o^=b[1],o^=b[2],h}))}function P(e,t){if(null==e)throw new Error(`'${t}' not specified.`)}function L(e,t){if("string"!=typeof e)throw new Error(`'${t}' must be a string.`)}function R(e){const{apiKey:t,sku:n,targetElement:o,baseUrl:i}=e;P(t,"apiKey"),L(t,"apiKey"),P(n,"sku"),L(n,"sku"),P(o,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new Error(`'${t}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&L(i,"baseUrl")}var A;!function(e){e[e.None=0]="None",e[e.AR=1]="AR",e[e.Preview=2]="Preview"}(A||(A={}));let x=A.None,S=0;const $=[];function M(){if(x===A.AR){const e=s();null==e||e.isPaused()||e.pause()}else if(x===A.Preview){const e=c();null==e||e.isPaused()||e.pause()}}function T(e){var t;x=e,$.forEach((e=>null==e?void 0:e.classList.remove("active"))),null===(t=$[x])||void 0===t||t.classList.add("active")}function k(e){return t(this,void 0,void 0,(function*(){R(e);const{apiKey:n,sku:o,targetElement:s}=e;f.update(e.baseUrl);const c=yield function(e,n){return t(this,void 0,void 0,(function*(){const o=yield i((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.spexx.ai/plugin?${new URLSearchParams({apiKey:e,sku:n})}`).catch((e=>{throw console.error(e),new Error("API unavailable.")}));if(!t.ok)throw new Error(`API call failed with status ${t.status}.`);return t}))));try{return yield o.json()}catch(e){throw console.error(e),new Error("API returned invalid body.")}}))}(n,o);!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new Error(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(s),s.style.position="relative";const p=function(){const e=document.createElement("div"),t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}();s.appendChild(p);const h=function(){const e=document.createElement("div");return e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e}();p.appendChild(h);const v=function(){const e=document.createElement("div"),t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="1",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const i=document.createElement("div");return i.textContent="Loading...",n.appendChild(i),{container:e,show:()=>{t.display=""},hide:()=>{t.display="none"}}}();p.appendChild(v.container);const{arUrl:y,previewUrl:g}=c;if(null!=y){const e=Promise.all([m(`${f}/shopar-deepar.js`),w(y)]);$[A.AR]=u("shopar-btn-vto","AR","Launch virtual try-on"),h.appendChild($[A.AR]),$[A.AR].onclick=()=>t(this,void 0,void 0,(function*(){const t=++S,n=A.AR,o=x===n?A.None:n;if(M(),T(o),x===A.None)return;v.show();const[,i]=yield e;if(S!==t)return;const s=(null==r&&(r=a()),r);p.contains(s.domElement)||p.appendChild(s.domElement),yield s.init(),S===t&&(yield s.parse(i),S===t&&(s.resume(),v.hide()))}))}if(null!=g){const e=255,n=Promise.all([m(`${f}/shopar-three.js`),C(g,(new Date).getTime()+e,Math.random()*e),w(`${f}/env/studio2.hdr`)]);$[A.Preview]=u("shopar-btn-3d","3D","Launch 3D preview"),h.appendChild($[A.Preview]),$[A.Preview].onclick=()=>t(this,void 0,void 0,(function*(){const e=++S,t=A.Preview,o=x===t?A.None:t;if(M(),T(o),x===A.None)return;v.show();const[,i,r]=yield n;if(S!==e)return;const s=(null==d&&(d=l()),d);p.contains(s.domElement)||(p.appendChild(s.domElement),s.updateSize()),yield s.parse(i,r),S===e&&(s.resume(),v.hide())}))}}))}const D={setup:function(e){return t(this,void 0,void 0,(function*(){!function(e,n){t(this,void 0,void 0,(function*(){try{yield n()}catch(t){throw t instanceof Error?new D.PluginError(`${e} failed: ${t.message}`):(console.error(t),new D.PluginError(`${e} failed.`))}}))}("setup",(()=>k(e)))}))},version:p,PluginError:class extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}};e.plugin=D}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n=[Uint8Array,Uint32Array],o=n.length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],r=[2,12,7,1],s=window[i[r[r[o]]]][i[r[r[r.length-1]]]],a=s.charCodeAt(o),c=a^a,d=new n[1]([c]);function l(){const e=(new TextEncoder).encode(s),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}const u=[1e3,2e3,4e3],h=u.length;function p(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=h)throw t;return yield new Promise((e=>setTimeout(e,u[n]))),p(e,n+1)}}))}let f;const m=()=>f,w=e=>{let t=!1;const n=[];e.then((()=>{t=!0,n.forEach((e=>e()))}));const o=e=>{t?e():n.push(e)},i={organizationId:"Unknown",sku:"Unknown"};let r,s=0;function a(e,t={}){t=Object.assign(Object.assign(Object.assign({},t),i),{vtoTime:(performance.now()-s)/1e3,vtoSessionId:r}),o((()=>{const{trackEventImpl:n}=window.ShopAR__analytics;n(e,t)}))}return{init:function(e,t){i.organizationId=e||"Unknown",i.sku=t||"Unknown",s=performance.now(),o((()=>{const{initializeImpl:e,uuidv4:t}=window.ShopAR__analytics;e(),r=t()}))},initialized:()=>a("initialized"),vtoLaunched:()=>a("vto_launched"),vtoCameraAsked:()=>a("vto_camera_asked"),vtoCameraGranted:()=>a("vto_camera_granted"),vtoCameraDenied:e=>a("vto_camera_denied",{error:e}),vtoInitSuccess:()=>a("vto_init_success"),previewLaunched:()=>a("preview_launched"),previewInteracted:()=>a("preview_interacted")}};let v;const g=()=>v,y=()=>{const e=m(),n=document.createElement("div"),o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.zIndex="1",o.display="none";const i=window.ShopAR__DeepAR;let r,s;const a={Glasses:"rigidFaceTrackingInit",Shoes:"footInit",Watches:void 0},c={Glasses:"user",Shoes:"environment",Watches:"environment"};let d;let l=!0;return{domElement:n,init:(o,d)=>t(void 0,void 0,void 0,(function*(){const l=null!=d?a[d]:void 0,u=null!=d?c[d]:"user";return null==s&&(s=t(void 0,void 0,void 0,(function*(){r=yield i.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:n,additionalOptions:{hint:l,cameraConfig:{facingMode:u,cameraPermissionAsked:()=>{e.vtoCameraAsked()},cameraPermissionGranted:()=>{e.vtoCameraGranted()}}}}),e.vtoInitSuccess()}))),s})),parse:e=>t(void 0,void 0,void 0,(function*(){return null==d&&(d=r.switchEffect(e)),d})),isPaused:()=>l,resume:()=>{l=!1,r.setPaused(l),o.display=""},pause:()=>{l=!0,r.setPaused(l),o.display="none"}}};let E;const b=()=>E,C=()=>{const e=m(),n=document.createElement("canvas"),o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.zIndex="1";const i=window.ShopAR__THREE,r=i.THREE,s=new r.WebGLRenderer({canvas:n,antialias:!0});s.outputEncoding=r.sRGBEncoding,s.toneMapping=r.LinearToneMapping,s.toneMappingExposure=Math.pow(1.2,5),s.setPixelRatio(2*window.devicePixelRatio),s.setClearColor(new r.Color(16777215)),s.useLegacyLights=!1;const a=new r.PerspectiveCamera(60,1,2,100);a.position.set(8,6,14);const c=new r.Scene,d=new i.OrbitControls(a,s.domElement);d.target.set(0,.03,0),d.dampingFactor=.3;{const t=function(e,t){let n;return()=>{n||e(),clearTimeout(n),n=setTimeout((()=>{n=void 0}),t)}}((()=>e.previewInteracted()),200);d.addEventListener("end",t)}{const e=new r.AmbientLight(new r.Color(16777215),.3),t=new r.DirectionalLight(new r.Color(16777215),.1);t.position.set(10,0,10);const n=new r.DirectionalLight(new r.Color(16777215),.1);n.position.set(-10,0,10),c.add(e,t,n)}const l=()=>{const e=n.clientWidth,t=n.clientHeight;n.width===e&&n.height===t||(s.setSize(e,t,!1),a.aspect=e/t,a.updateProjectionMatrix())};let u;let h=!1;const p=()=>{h||(requestAnimationFrame(p),l(),d.update(),s.render(c,a))};return{domElement:n,updateSize:l,parse:(e,n)=>t(void 0,void 0,void 0,(function*(){return null==u&&(u=t(void 0,void 0,void 0,(function*(){const t=new i.RGBELoader,o=function(e,t){const n=e.THREE,o=new n.DataTexture(t.data,t.width,t.height,void 0,t.type,void 0,n.ClampToEdgeWrapping,n.ClampToEdgeWrapping,n.LinearFilter,n.LinearFilter,1,n.LinearEncoding);return o.flipY=!0,o.generateMipmaps=!1,o.needsUpdate=!0,o}(i,t.parse(n));o.mapping=r.EquirectangularReflectionMapping,o.encoding=r.LinearEncoding,c.environment=o;const a=(new i.GLTFLoader).setDRACOLoader((new i.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${r.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new i.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${r.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(s)).setMeshoptDecoder("function"==typeof i.MeshoptDecoder?i.MeshoptDecoder():i.MeshoptDecoder),d=yield a.parseAsync(e.buffer,"");c.add(d.scene),c.traverse((e=>{if(e instanceof r.Mesh){const t=e.material;t.depthWrite=!0,t instanceof r.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}))}))),u})),isPaused:()=>h,resume:()=>{h=!1,p(),o.display=""},pause:()=>{h=!0,o.display="none"}}},A="0.0.3";let P=`https://cdn.jsdelivr.net/npm/shopar-plugin@${A}/dist`;const S={update:e=>{null!=e&&(P=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>P};function L(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}function R(e,t,n,o){const i=document.createElement("button");if(i.id=e,i.type="button",i.className="shopar-btn",null!=o){const e=L("1.75rem",o);i.appendChild(e)}{const e=document.createElement("span");e.textContent=t,i.appendChild(e)}return i.ariaLabel=n,i.style.zIndex="2",i}function k(e){return t(this,void 0,void 0,(function*(){const n=yield p((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new Error("Resource unavailable.")}));if(!t.ok)throw new Error(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield n.blob()).arrayBuffer()}catch(e){throw console.error(e),new Error("Resource has invalid body.")}}))}function x(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}function $(e,o,i){return t(this,void 0,void 0,(function*(){let r="glb".charCodeAt(0),s="3d".charCodeAt(0);r>>=1,r+=s;const a=String.fromCharCode(r+14);s>>=2,r^=s+2;const l=String.fromCharCode(r-3);r^=5;const u=String.fromCharCode(r-7);r^=2;const h=String.fromCharCode(r-7),f=window[`${u}${l+a+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${h}`],m=yield p((()=>t(this,void 0,void 0,(function*(){const t=yield f(`${e}`).catch((()=>{throw new Error("Unknown error.")}));if(!t.ok)throw new Error("Unknown error.");return t})))),w=new n[0](yield(yield m.blob().catch((()=>{throw new Error("Unknown error.")}))).arrayBuffer().catch((()=>{throw new Error("Unknown error.")})));i+=s;const v=w.byteLength;if(d[c]=Math.min(76,o)*((r>>5)-1),152===d[c]&&(d[c]=v),i==c)return w;i=c,i^=c;for(let e=0,t=w.length;e<t;e++)d[c]^=d[i]<<13,d[c]^=d[i]>>17,d[c]^=d[i]<<5,w[e]=w[e]^d[c];return i^=d[0],i^=d[1],i^=d[2],w}))}function I(e,t){if(null==e)throw new Error(`'${t}' not specified.`)}function T(e,t){if("string"!=typeof e)throw new Error(`'${t}' must be a string.`)}function _(e){const{apiKey:t,sku:n,targetElement:o,baseUrl:i}=e;I(t,"apiKey"),T(t,"apiKey"),I(n,"sku"),T(n,"sku"),I(o,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new Error(`'${t}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&T(i,"baseUrl")}var M;!function(e){e[e.None=0]="None",e[e.AR=1]="AR",e[e.Preview=2]="Preview"}(M||(M={}));let N,U=M.None,D=0;const j=[];let z;function G(){if(U===M.AR){const e=g();null==e||e.isPaused()||e.pause()}else if(U===M.Preview){const e=b();null==e||e.isPaused()||e.pause()}}function O(e){if(U=e,U===M.None){const e=j.filter((e=>null!=e));N.replaceChildren(...e)}else N.replaceChildren(z)}function K(e){return t(this,void 0,void 0,(function*(){_(e);const{apiKey:n,sku:o,targetElement:i}=e;S.update(e.baseUrl);const r=function(e,n){return t(this,void 0,void 0,(function*(){const o=yield p((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:e,sku:n,sid:l()})}`).catch((e=>{throw console.error(e),new Error("API unavailable.")}));if(!t.ok)throw new Error(`API call failed with status ${t.status}.`);return t}))));try{return yield o.json()}catch(e){throw console.error(e),new Error("API returned invalid body.")}}))}(n,o),s=(a=x(`${S}/shopar-analytics.js`),null==f&&(f=w(a)),f);var a;s.init(n,o),function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new Error(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(i),i.style.position="relative";const c=function(){const e=document.createElement("div"),t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}();i.appendChild(c),N=function(){const e=document.createElement("div");return e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e}(),c.appendChild(N),z=R("shopar-btn-close","Close","Close ShopAR view",`${S}/img/icons/close.svg`),z.onclick=()=>{d.hide(),u.hide(),G(),O(M.None)};const d=function(){const e=document.createElement("div"),t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="1",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const i=document.createElement("div");return i.className="shopar-spinner",n.appendChild(i),{container:e,show:()=>{t.display=""},hide:()=>{t.display="none"}}}();c.appendChild(d.container);const u=function(){const e=document.createElement("div"),t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="1",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const i=L("4rem",`${S}/img/icons/close.svg`);n.appendChild(i);const r=document.createElement("div");r.className="shopar-error-title",r.textContent="Camera Error",n.appendChild(r);const s=document.createElement("div");return s.className="shopar-error-body",s.textContent="Please refresh the page and allow the use of camera.",n.appendChild(s),{container:e,show:()=>{t.display=""},hide:()=>{t.display="none"}}}();c.appendChild(u.container);const{category:h,arUrl:m,arKey:g,previewUrl:b}=yield r;if(s.initialized(),null!=m){const e=Promise.all([x(`${S}/shopar-deepar.js`),k(m)]),n={Glasses:`${S}/img/icons/glasses.svg`,Shoes:`${S}/img/icons/shoe.svg`,Watches:`${S}/img/icons/watch.svg`},o=null!=h&&n[h]||n.Glasses;j[M.AR]=R("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",o),N.appendChild(j[M.AR]),j[M.AR].onclick=()=>t(this,void 0,void 0,(function*(){const t=++D,n=M.AR,o=U===n?M.None:n;if(G(),O(o),U===M.None)return;s.vtoLaunched(),u.hide(),d.show();const[,i]=yield e;if(D!==t)return;const r=(null==v&&(v=y()),v);c.contains(r.domElement)||c.appendChild(r.domElement);try{yield r.init(g,h)}catch(e){return s.vtoCameraDenied(e),d.hide(),void u.show()}D===t&&(yield r.parse(i),D===t&&(r.resume(),d.hide()))}))}if(null!=b){const e=255,n=Promise.all([x(`${S}/shopar-three.js`),$(b,(new Date).getTime()+e,Math.random()*e),k(`${S}/env/studio2.hdr`)]);j[M.Preview]=R("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${S}/img/icons/cube.svg`),N.appendChild(j[M.Preview]),j[M.Preview].onclick=()=>t(this,void 0,void 0,(function*(){const e=++D,t=M.Preview,o=U===t?M.None:t;if(G(),O(o),U===M.None)return;s.previewLaunched(),u.hide(),d.show();const[,i,r]=yield n;if(D!==e)return;const a=(null==E&&(E=C()),E);c.contains(a.domElement)||(c.appendChild(a.domElement),a.updateSize()),yield a.parse(i,r),D===e&&(a.resume(),d.hide())}))}}))}const W={setup:function(e){return t(this,void 0,void 0,(function*(){!function(e,n){t(this,void 0,void 0,(function*(){try{yield n()}catch(t){throw t instanceof Error?new W.PluginError(`${e} failed: ${t.message}`):(console.error(t),new W.PluginError(`${e} failed.`))}}))}("setup",(()=>K(e)))}))},version:A,PluginError:class extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}};e.plugin=W}));
@@ -0,0 +1,38 @@
1
+ .shopar-btn-container {
2
+ position: absolute;
3
+ width: 100%;
4
+ bottom: 0;
5
+ padding-bottom: 2rem;
6
+ display: flex;
7
+ justify-content: center;
8
+ gap: 0.5rem;
9
+ pointer-events: none;
10
+ }
11
+ .shopar-btn {
12
+ padding: 0.5rem 0.75rem;
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: center;
16
+ gap: 0.25rem;
17
+ background-color: #ffffff;
18
+ border: 1px solid #dddddd;
19
+ border-radius: 9999px;
20
+ cursor: pointer;
21
+ pointer-events: auto;
22
+ }
23
+ .shopar-btn:hover {
24
+ background-color: #f5f5f5;
25
+ }
26
+ @keyframes shopar-spin {
27
+ to {
28
+ transform: rotate(360deg);
29
+ }
30
+ }
31
+ .shopar-spinner {
32
+ width: 4rem;
33
+ height: 4rem;
34
+ border-radius: 9999px;
35
+ background: conic-gradient(transparent 0deg, transparent 90deg, #5fb9ec 90deg, #773cd8 180deg, transparent 180deg, transparent 270deg, #5fb9ec 270deg, #773cd8 360deg);
36
+ mask: radial-gradient(farthest-side, transparent 75%, black 75%);
37
+ animation: shopar-spin 1s linear infinite;
38
+ }
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "shopar-plugin",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Plugin for the Web that seamlessly integrates into your webpage to create embedded virtual try-on and 3D preview capabilities.",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
7
- "build": "yarn run clean && rollup -c --environment BUILD_PRODUCTION",
8
- "build-dev": "yarn run clean && rollup -c",
7
+ "build-prod": "yarn run clean && rollup -c --environment MINIFY,ANALYTICS:prod.js",
8
+ "build-stage": "yarn run clean && rollup -c --environment MINIFY,ANALYTICS:stage.js",
9
+ "build-debug": "yarn run clean && rollup -c",
10
+ "build": "yarn run clean && rollup -c --environment MINIFY",
9
11
  "generate-version": "node ci/generate-version.js",
10
12
  "prepare-release": "node ci/prepare-release.js",
11
13
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -30,8 +32,10 @@
30
32
  "author": "DeepAR",
31
33
  "license": "SEE LICENSE IN LICENSE",
32
34
  "dependencies": {
35
+ "@amplitude/analytics-browser": "^2.3.3",
33
36
  "deepar": "5.4.1",
34
- "three": "0.151.3"
37
+ "three": "0.151.3",
38
+ "uuid": "^9.0.1"
35
39
  },
36
40
  "devDependencies": {
37
41
  "@rollup/plugin-commonjs": "^25.0.4",
@@ -40,6 +44,7 @@
40
44
  "@rollup/plugin-typescript": "^11.1.2",
41
45
  "@trivago/prettier-plugin-sort-imports": "^4.2.0",
42
46
  "@types/three": "0.151.0",
47
+ "@types/uuid": "^9.0.6",
43
48
  "@typescript-eslint/eslint-plugin": "^6.4.1",
44
49
  "@typescript-eslint/parser": "^6.4.1",
45
50
  "eslint": "^8.47.0",