@singlebase/elements 0.3.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +2 -0
  2. package/dist/{display-8HEcKYR4.js → authui-display-CKfGK5va.js} +519 -502
  3. package/dist/authui-display-CKfGK5va.js.map +1 -0
  4. package/dist/{display-CLDNNZQy.cjs → authui-display-aWNht0cW.cjs} +38 -58
  5. package/dist/authui-display-aWNht0cW.cjs.map +1 -0
  6. package/dist/authui.cjs +1 -1
  7. package/dist/authui.d.ts +9 -9
  8. package/dist/authui.js +2 -2
  9. package/dist/chat-C-gsskho.cjs +3258 -0
  10. package/dist/chat-C-gsskho.cjs.map +1 -0
  11. package/dist/chat-CEh6RygY.js +5746 -0
  12. package/dist/chat-CEh6RygY.js.map +1 -0
  13. package/dist/chat-messages.d.ts +115 -0
  14. package/dist/chat.cjs +2 -0
  15. package/dist/chat.cjs.map +1 -0
  16. package/dist/chat.d.ts +11 -0
  17. package/dist/chat.js +15 -0
  18. package/dist/chat.js.map +1 -0
  19. package/dist/elements/{account-screen.d.ts → authui-account.d.ts} +1 -1
  20. package/dist/elements/{base.d.ts → authui-base.d.ts} +2 -0
  21. package/dist/elements/{buttons.d.ts → authui-buttons.d.ts} +2 -2
  22. package/dist/elements/{display.d.ts → authui-display.d.ts} +2 -2
  23. package/dist/elements/{form-base.d.ts → authui-form-base.d.ts} +1 -1
  24. package/dist/elements/{guard.d.ts → authui-guard.d.ts} +1 -1
  25. package/dist/elements/{auth-screen.d.ts → authui.d.ts} +8 -4
  26. package/dist/elements/chat.d.ts +455 -0
  27. package/dist/elements/uploader.d.ts +14 -0
  28. package/dist/files-DDJWPzZW.js +215 -0
  29. package/dist/files-DDJWPzZW.js.map +1 -0
  30. package/dist/files-DyxcjZsx.cjs +75 -0
  31. package/dist/files-DyxcjZsx.cjs.map +1 -0
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.d.ts +3 -2
  34. package/dist/index.js +34 -21
  35. package/dist/index.js.map +1 -1
  36. package/dist/singlebase-elements.min.js +8044 -2120
  37. package/dist/singlebase-elements.min.js.map +1 -1
  38. package/dist/styles/branding.d.ts +5 -0
  39. package/dist/styles/chat.d.ts +6 -0
  40. package/dist/styles/tokens.d.ts +3 -1
  41. package/dist/{uploader-eFYKpk8b.cjs → uploader-660JIgIN.cjs} +55 -114
  42. package/dist/uploader-660JIgIN.cjs.map +1 -0
  43. package/dist/{uploader-D-Da1trc.js → uploader-vfczkX51.js} +376 -507
  44. package/dist/uploader-vfczkX51.js.map +1 -0
  45. package/dist/uploader.cjs +1 -1
  46. package/dist/uploader.js +5 -4
  47. package/dist/uploader.js.map +1 -1
  48. package/dist/utils/branding.d.ts +8 -0
  49. package/dist/utils/markdown.d.ts +165 -0
  50. package/dist/utils/svg.d.ts +10 -0
  51. package/package.json +13 -5
  52. package/dist/display-8HEcKYR4.js.map +0 -1
  53. package/dist/display-CLDNNZQy.cjs.map +0 -1
  54. package/dist/uploader-D-Da1trc.js.map +0 -1
  55. package/dist/uploader-eFYKpk8b.cjs.map +0 -1
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The "… by Singlebase" credit, identical in every element: same font, size,
3
+ * spacing and hover. Each element only decides where it sits.
4
+ */
5
+ export declare const brandingStyles: import("lit").CSSResult;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * <singlebase-chat> styles. Every colour comes from the shared --sb-* tokens
3
+ * (plus --sb-hover, --sb-ink-2 and --sb-divider, which only the chat uses),
4
+ * so a page themes the chat, the auth widget and the uploader in one place.
5
+ */
6
+ export declare const chatStyles: import("lit").CSSResult;
@@ -14,6 +14,8 @@ export declare const TOKEN_DEFAULTS: {
14
14
  readonly accent: "#111111";
15
15
  readonly onAccent: "#ffffff";
16
16
  readonly radius: "4px";
17
+ /** Multiplies every corner. The `radius` attribute sets it per element. */
18
+ readonly radiusScale: "1";
17
19
  readonly surface: "#ffffff";
18
20
  readonly surfaceAlt: "#fafafa";
19
21
  readonly ink: "#16181a";
@@ -37,7 +39,7 @@ export declare const TOKEN_DEFAULTS: {
37
39
  * Base host layout plus the theme="dark"/density="compact" attribute
38
40
  * overrides. These overrides are legitimate unconditional assignments —
39
41
  * they only fire when *this* element carries the attribute — but every
40
- * composite element (auth-screen, reset-password-form, etc.) must forward
42
+ * composite element (<singlebase-authui>, <singlebase-authui-account>) must forward
41
43
  * theme/density/field-style to the singlebase-* children it renders for the
42
44
  * override to reach elements that don't carry the attribute directly.
43
45
  */
@@ -1,40 +1,4 @@
1
- "use strict";var ue=t=>{throw TypeError(t)};var fe=(t,a,e)=>a.has(t)||ue("Cannot "+e);var d=(t,a,e)=>(fe(t,a,"read from private field"),e?e.call(t):a.get(t)),c=(t,a,e)=>a.has(t)?ue("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(t):a.set(t,e),p=(t,a,e,r)=>(fe(t,a,"write to private field"),r?r.call(t,e):a.set(t,e),e);const n=require("lit"),u=require("lit/decorators.js"),Me=require("@singlebase/core"),ne={font:'"Geist", -apple-system, "Segoe UI", Helvetica, sans-serif',mono:'"Geist Mono", ui-monospace, monospace',accent:"#111111",onAccent:"#ffffff",radius:"4px",surface:"#ffffff",surfaceAlt:"#fafafa",ink:"#16181a",mutedInk:"#61666c",border:"#e4e6e9",borderStrong:"#cdd1d6",danger:"#b4231a",dangerBg:"#fdf1f0",dangerBorder:"#f3d6d3",dangerOutline:"#e8c4c0",dangerPanelBorder:"#efd9d6",dangerPanelBg:"#fdf7f6",ok:"#0f6b4a",okBg:"#f0f7f3",okBorder:"#cfe5da",gap:"16px",pad:"20px",fieldPad:"11px 13px"},me=n.css`
2
- :host {
3
- display: block;
4
- box-sizing: border-box;
5
- font-family: var(--sb-font, ${n.unsafeCSS(ne.font)});
6
- color: var(--sb-ink, ${n.unsafeCSS(ne.ink)});
7
- }
8
-
9
- :host([theme="dark"]) {
10
- /* The light default accent is near-black, which disappears on a dark
11
- surface — primary buttons and links both use it. A host that sets its
12
- own --sb-accent still wins: outer-page declarations beat :host rules. */
13
- --sb-accent: #f3f4f5;
14
- --sb-on-accent: #17181b;
15
- --sb-surface: #17181b;
16
- --sb-surface-alt: #202226;
17
- --sb-ink: #f3f4f5;
18
- --sb-muted-ink: #a2a8ae;
19
- --sb-border: #2c2f34;
20
- --sb-border-strong: #3a3e44;
21
- --sb-danger: #f08379;
22
- --sb-danger-bg: rgba(240, 131, 121, 0.1);
23
- --sb-danger-border: rgba(240, 131, 121, 0.3);
24
- --sb-danger-outline: rgba(240, 131, 121, 0.4);
25
- --sb-danger-panel-border: rgba(240, 131, 121, 0.3);
26
- --sb-danger-panel-bg: rgba(240, 131, 121, 0.06);
27
- --sb-ok: #6fd1a6;
28
- --sb-ok-bg: rgba(111, 209, 166, 0.1);
29
- --sb-ok-border: rgba(111, 209, 166, 0.28);
30
- }
31
-
32
- :host([density="compact"]) {
33
- --sb-gap: 12px;
34
- --sb-pad: 16px;
35
- --sb-field-pad: 9px 11px;
36
- }
37
- `,xe=n.css`
1
+ "use strict";var ce=r=>{throw TypeError(r)};var pe=(r,a,e)=>a.has(r)||ce("Cannot "+e);var l=(r,a,e)=>(pe(r,a,"read from private field"),e?e.call(r):a.get(r)),d=(r,a,e)=>a.has(r)?ce("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(r):a.set(r,e),c=(r,a,e,t)=>(pe(r,a,"write to private field"),t?t.call(r,e):a.set(r,e),e);const s=require("lit"),p=require("lit/decorators.js"),Ue=require("@singlebase/core"),f=require("./files-DyxcjZsx.cjs"),be=s.css`
38
2
  /* ── layout primitives ───────────────────────────────────── */
39
3
  .stack {
40
4
  display: flex;
@@ -158,7 +122,7 @@
158
122
  color: var(--sb-ink, #16181a);
159
123
  background: var(--sb-surface-alt, #fafafa);
160
124
  border: 1px solid var(--sb-border, #e4e6e9);
161
- border-radius: var(--sb-radius, 4px);
125
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
162
126
  padding: var(--sb-field-pad, 11px 13px);
163
127
  outline: none;
164
128
  }
@@ -228,7 +192,7 @@
228
192
  font: inherit;
229
193
  font-size: 13.5px;
230
194
  font-weight: 500;
231
- border-radius: var(--sb-radius, 4px);
195
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
232
196
  cursor: pointer;
233
197
  padding: 9px 14px;
234
198
  border: 1px solid transparent;
@@ -404,7 +368,7 @@
404
368
  .notice {
405
369
  font-size: 13px;
406
370
  line-height: 1.45;
407
- border-radius: var(--sb-radius, 4px);
371
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
408
372
  padding: 10px 12px;
409
373
  }
410
374
 
@@ -522,7 +486,7 @@
522
486
 
523
487
  .acc-item {
524
488
  border: 1px solid var(--sb-border, #e4e6e9);
525
- border-radius: var(--sb-radius, 4px);
489
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
526
490
  overflow: hidden;
527
491
  background: transparent;
528
492
  transition:
@@ -637,7 +601,7 @@
637
601
  padding: 10px 12px;
638
602
  background: var(--sb-surface-alt, #fafafa);
639
603
  border: 1px solid var(--sb-border, #e4e6e9);
640
- border-radius: var(--sb-radius, 4px);
604
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
641
605
  }
642
606
 
643
607
  .invite-label {
@@ -804,7 +768,7 @@
804
768
  padding: 14px;
805
769
  background: var(--sb-surface-alt, #fafafa);
806
770
  border: 1px solid var(--sb-border, #e4e6e9);
807
- border-radius: var(--sb-radius, 4px);
771
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
808
772
  }
809
773
 
810
774
  /* 2FA switch */
@@ -853,7 +817,7 @@
853
817
  flex: 0 0 auto;
854
818
  width: 74px;
855
819
  height: 74px;
856
- border-radius: var(--sb-radius, 4px);
820
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
857
821
  background: var(--sb-surface-alt, #fafafa);
858
822
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
859
823
  display: flex;
@@ -885,7 +849,7 @@
885
849
  gap: 12px;
886
850
  padding: 10px 12px;
887
851
  border: 1px solid var(--sb-border, #e4e6e9);
888
- border-radius: var(--sb-radius, 4px);
852
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
889
853
  background: var(--sb-surface-alt, #fafafa);
890
854
  }
891
855
 
@@ -949,7 +913,7 @@
949
913
  font: inherit;
950
914
  text-align: left;
951
915
  padding: 10px 11px;
952
- border-radius: var(--sb-radius, 4px);
916
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
953
917
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
954
918
  background: transparent;
955
919
  cursor: pointer;
@@ -1001,7 +965,7 @@
1001
965
  gap: 12px;
1002
966
  padding: 14px;
1003
967
  border: 1px solid var(--sb-danger-panel-border, #efd9d6);
1004
- border-radius: var(--sb-radius, 4px);
968
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
1005
969
  background: var(--sb-danger-panel-bg, #fdf7f6);
1006
970
  }
1007
971
 
@@ -1010,86 +974,82 @@
1010
974
  color: var(--sb-muted-ink, #61666c);
1011
975
  font-style: italic;
1012
976
  }
1013
- `;function ve(t,a,e){if(!t||!a)return null;let r;try{r=new URL(a)}catch{return null}let o;try{o=new URL(t,r.href)}catch{return e==null||e(`"${t}" is not a valid URL`),null}return o.protocol!=="http:"&&o.protocol!=="https:"?(e==null||e(`refusing redirect to unsupported scheme "${o.protocol}"`),null):o.origin!==r.origin?(e==null||e(`refusing cross-origin redirect to ${o.origin}; same-origin only`),null):o.href===r.href?null:o.href}const ie={heading:"Upload files",description:"Add one or more files. You can review the list before uploading.",dropTitle:"Drag and drop files here",dropSub:"or browse from your device",hintUpTo:"up to {size} each",chooseFiles:"Choose files",chooseFile:"Choose file",addMore:"+ Add more files",remove:"Remove",rename:"Rename",retry:"Retry",uploadCtaOne:"Upload {n} file",uploadCtaMany:"Upload {n} files",attachments:"Attachments",dropOrChoose:"Drop files or choose",checking:"Checking…",pagesLabel:"{n} pages",countOne:"{n} file of {max}",countMany:"{n} files of {max}",uploading:"Uploading…",uploaded:"Uploaded",failedLabel:"Failed",errTooMany:"You can upload up to {max} files.",errTooLarge:"{name} is larger than {size}.",errTooSmall:"{name} is smaller than {size}.",errDuplicate:"{name} is already in the list.",errType:"{name} isn't an accepted file type.",errNoClient:"No Singlebase client found on this page.",errUpload:"Upload failed.",errProtected:"{name} is password protected.",errTooManyPages:"{name} has {pages} pages; the limit is {max}.",brandingLabel:"Files by Singlebase"};function ye(t){return t?{...ie,...t}:ie}function x(t,a){return t.replace(/\{(\w+)\}/g,(e,r)=>r in a?String(a[r]):e)}const Te={b:1,kb:1024,mb:1024*1024,gb:1024*1024*1024};function ae(t){if(typeof t=="number")return t>0?t:0;if(!t)return 0;const a=String(t).trim().toLowerCase().match(/^([\d.]+)\s*(b|kb|mb|gb)?$/);if(!a)return 0;const e=Number.parseFloat(a[1]);return!Number.isFinite(e)||e<=0?0:Math.round(e*(Te[a[2]??"b"]??1))}function Z(t){return t<1024?`${t} B`:t<1024*1024?`${Math.round(t/1024)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function Q(t){const a=t.lastIndexOf(".");return a<=0||a===t.length-1?"":t.slice(a+1).toLowerCase()}function Le(t){return Q(t).toUpperCase().slice(0,4)}function Fe(t,a,e){const r=t.split(",").map(g=>g.trim().toLowerCase()).filter(Boolean);if(!r.length)return!0;const o=a.toLowerCase(),l=(e||"").toLowerCase();return r.some(g=>g.startsWith(".")?o.endsWith(g):g.endsWith("/*")?l.startsWith(g.slice(0,-1)):l===g)}function Oe(t){const a=t.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{if(e.startsWith("."))return e.slice(1).toUpperCase();if(e.endsWith("/*"))return e.slice(0,-2).toUpperCase();const r=e.indexOf("/");return(r>=0?e.slice(r+1):e).toUpperCase()});return[...new Set(a)].join(", ")}function De(t){return`${t.name}:${t.size}:${t.lastModified??0}`}function je(t,a){const e=a.trim().replace(/[/\\]/g,"");if(!e)return t;const r=t.lastIndexOf("."),o=r>0?t.slice(r):"";return o?e.toLowerCase().endsWith(o.toLowerCase())?e:e+o:e}const we={pages:null,encrypted:null},ge=16*1024*1024,Ae=2*1024*1024,Ee=40,Ne=4*1024*1024,ke=new Set(["docx","pptx","xlsx"]);async function ze(t,a){try{if(a==="pdf")return await Be(t);if(ke.has(a))return await Re(t,a)}catch{}return we}function Ue(t){return t==="pdf"||ke.has(t)}async function Be(t){const a=await ee(t.slice(0,ge)),e=t.size>ge?await ee(t.slice(Math.max(0,t.size-Ae))):null,r=te(a)+(e?te(e):""),o=/\/Encrypt[\s/<>\]]/.test(r);let l=$e(r);return l===null&&(l=await Pe(a)),{pages:l,encrypted:o}}function $e(t){if(/\/Type\s*\/Pages/.test(t)){let e=0;for(const r of t.matchAll(/\/Count\s+(\d+)/g))e=Math.max(e,Number(r[1]));if(e>0)return e}const a=t.match(/\/Type\s*\/Page[^s]/g);return a!=null&&a.length?a.length:null}async function Pe(t){if(typeof DecompressionStream>"u")return null;const a=te(t);let e="",r=0;for(const o of a.matchAll(/stream\r?\n/g)){if(r>=Ee||e.length>=Ne)break;const l=o.index+o[0].length;let g=a.indexOf("endstream",l);if(g<0)break;for(;g>l&&(a[g-1]===`
1014
- `||a[g-1]==="\r");)g-=1;r+=1;try{const i=await Se(t.subarray(l,g),"deflate");e+=te(i)}catch{}}return e?$e(e):null}async function Re(t,a){const e=await ee(t.slice(0,8));if(Ie(e))return{pages:null,encrypted:!0};if(e[0]!==80||e[1]!==75)return we;const r=await Ge(t,"docProps/app.xml");if(!r)return{pages:null,encrypted:!1};const o=a==="pptx"?"Slides":"Pages",l=new TextDecoder().decode(r).match(new RegExp(`<${o}>(\\d+)</${o}>`));return{pages:l?Number(l[1]):null,encrypted:!1}}function Ie(t){return[208,207,17,224,161,177,26,225].every((e,r)=>t[r]===e)}async function Ge(t,a){const e=Math.min(t.size,66e3),r=new DataView(await t.slice(t.size-e).arrayBuffer());let o=-1;for(let h=r.byteLength-22;h>=0;h--)if(r.getUint32(h,!0)===101010256){o=h;break}if(o<0)return null;const l=r.getUint32(o+12,!0),g=r.getUint32(o+16,!0);if(!l||g===4294967295)return null;const i=new DataView(await t.slice(g,g+l).arrayBuffer()),s=new TextDecoder;let b=0;for(;b+46<=i.byteLength&&i.getUint32(b,!0)===33639248;){const h=i.getUint16(b+10,!0),m=i.getUint32(b+20,!0),v=i.getUint16(b+28,!0),X=i.getUint16(b+30,!0),re=i.getUint16(b+32,!0),oe=i.getUint32(b+42,!0);if(s.decode(new Uint8Array(i.buffer,i.byteOffset+b+46,v))===a){const de=new DataView(await t.slice(oe,oe+30).arrayBuffer()),ce=oe+30+de.getUint16(26,!0)+de.getUint16(28,!0),pe=await ee(t.slice(ce,ce+m));return h===0?pe:h===8&&typeof DecompressionStream<"u"?await Se(pe,"deflate-raw"):null}b+=46+v+X+re}return null}async function ee(t){return new Uint8Array(await t.arrayBuffer())}async function Se(t,a){const e=new Blob([t]).stream().pipeThrough(new DecompressionStream(a));return new Uint8Array(await new Response(e).arrayBuffer())}function te(t){let a="";for(let r=0;r<t.length;r+=32768)a+=String.fromCharCode(...t.subarray(r,r+32768));return a}var Ce=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ke=(t,a,e)=>a in t?Ce(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,f=(t,a,e,r)=>{for(var o=r>1?void 0:r?_e(a,e):a,l=t.length-1,g;l>=0;l--)(g=t[l])&&(o=(r?g(a,e,o):g(o))||o);return r&&o&&Ce(a,e,o),o},We=(t,a,e)=>Ke(t,a+"",e);const se={fromAttribute:t=>{if(!t)return{};try{const a=JSON.parse(t);return a&&typeof a=="object"?a:{}}catch{return console.warn("[singlebase-uploader] an attribute holds invalid JSON; ignoring it"),{}}},toAttribute:t=>JSON.stringify(t??{})},le={fromAttribute:t=>t===null?!0:t!=="false",toAttribute:t=>t?null:"false"},be=["view","dropzone","allowRename","autoUpload","branding","logoUrl","logoText","heading","description","maxFiles","maxSize","minSize","accept","rules","bucket","publicRead","redirectUrl","metadata","options","messages","theme","density","onComplete","onError"];var w,k,z,U,$,S,C,M,T,L,F,O,D,j,A,E,N,B,P,R,I,G,_,K,W,q,Y,H,V,J,he;exports.SinglebaseUploader=(he=class extends n.LitElement{constructor(){super(...arguments);c(this,w,null);c(this,k,{});c(this,z);c(this,U);c(this,$,"full");c(this,S,!0);c(this,C,!0);c(this,M,!1);c(this,T,!0);c(this,L,"");c(this,F,"");c(this,O,"");c(this,D,"");c(this,j,10);c(this,A,"25MB");c(this,E,0);c(this,N,"");c(this,B,{});c(this,P,"default");c(this,R,{});c(this,I,{});c(this,G,!1);c(this,_,"");c(this,K,null);c(this,W,null);c(this,q,[]);c(this,Y,"");c(this,H,!1);c(this,V,!1);c(this,J,"")}get client(){return d(this,w)}set client(e){p(this,w,e)}get messages(){return d(this,k)}set messages(e){p(this,k,e)}get theme(){return d(this,z)}set theme(e){p(this,z,e)}get density(){return d(this,U)}set density(e){p(this,U,e)}get view(){return d(this,$)}set view(e){p(this,$,e)}get dropzone(){return d(this,S)}set dropzone(e){p(this,S,e)}get allowRename(){return d(this,C)}set allowRename(e){p(this,C,e)}get autoUpload(){return d(this,M)}set autoUpload(e){p(this,M,e)}get branding(){return d(this,T)}set branding(e){p(this,T,e)}get logoUrl(){return d(this,L)}set logoUrl(e){p(this,L,e)}get logoText(){return d(this,F)}set logoText(e){p(this,F,e)}get heading(){return d(this,O)}set heading(e){p(this,O,e)}get description(){return d(this,D)}set description(e){p(this,D,e)}get maxFiles(){return d(this,j)}set maxFiles(e){p(this,j,e)}get maxSize(){return d(this,A)}set maxSize(e){p(this,A,e)}get minSize(){return d(this,E)}set minSize(e){p(this,E,e)}get accept(){return d(this,N)}set accept(e){p(this,N,e)}get rules(){return d(this,B)}set rules(e){p(this,B,e)}get bucket(){return d(this,P)}set bucket(e){p(this,P,e)}get metadata(){return d(this,R)}set metadata(e){p(this,R,e)}get options(){return d(this,I)}set options(e){p(this,I,e)}get publicRead(){return d(this,G)}set publicRead(e){p(this,G,e)}get redirectUrl(){return d(this,_)}set redirectUrl(e){p(this,_,e)}get onComplete(){return d(this,K)}set onComplete(e){p(this,K,e)}get onError(){return d(this,W)}set onError(e){p(this,W,e)}get items(){return d(this,q)}set items(e){p(this,q,e)}get notice(){return d(this,Y)}set notice(e){p(this,Y,e)}get busy(){return d(this,H)}set busy(e){p(this,H,e)}get dragging(){return d(this,V)}set dragging(e){p(this,V,e)}get editing(){return d(this,J)}set editing(e){p(this,J,e)}get msg(){return ye(this.messages)}get resolvedClient(){return this.client??Me.getDefaultClient()??null}get files(){return this.items}get percent(){const e=this.items.filter(r=>r.status!=="ready");return e.length?Math.round(e.reduce((r,o)=>r+o.percent,0)/e.length):0}open(){var e;(e=this.renderRoot.querySelector("input[type=file]"))==null||e.click()}set config(e){const r=this;for(const o of be)e&&o in e&&(r[o]=e[o])}get config(){const e=this;return Object.fromEntries(be.map(r=>[r,e[r]]))}clear(){this.items.forEach(y),this.items=[],this.notice=""}disconnectedCallback(){super.disconnectedCallback(),this.items.forEach(y)}async upload(){var g;if(this.busy)return;const e=this.items.filter(i=>i.status==="ready"||i.status==="error");if(!e.length)return;const r=this.resolvedClient;if(!r){this.fail(this.msg.errNoClient);return}this.busy=!0,this.notice="";for(const i of e)i.status="uploading",i.percent=0,i.error="";this.items=[...this.items];const o=new Map,l=e.map(i=>{const s={file:i.file,filename:i.file.name};return this.bucket&&(s.bucket=this.bucket),this.publicRead&&(s.publicRead=!0),i.name!==i.file.name&&(s.newName=i.name),Object.keys(this.metadata??{}).length&&(s.metadata={...this.metadata}),Object.keys(this.options??{}).length&&(s.options={...this.options}),o.set(s,i),s});try{const i=await r.files.upload(l,{onProgress:h=>{const m=o.get(h.input);m&&(m.percent=h.percent,this.items=[...this.items],this.emit("singlebase-upload-progress",{file:m,percent:this.percent}))}});for(const h of i.completed){const m=o.get(h.input);m&&(m.status="done",m.percent=100,m.record=h.file)}for(const h of i.failed){const m=o.get(h.input);m&&(m.status="error",m.error=h.error.message||h.error.code)}this.items=[...this.items];const s=i.completed.map(h=>o.get(h.input)).filter(Boolean),b=i.failed.map(h=>o.get(h.input)).filter(Boolean);this.emit("singlebase-upload-complete",{completed:s,failed:b}),(g=this.onComplete)==null||g.call(this,{completed:s,failed:b}),b.length?this.notice=this.msg.errUpload:this.redirect()}catch(i){for(const s of e)s.status="error",s.error="";this.items=[...this.items],this.fail(Ye(i)||this.msg.errUpload)}finally{this.busy=!1}}ruleFor(e){const r=Q(e);if(!r)return null;for(const[o,l]of Object.entries(this.rules??{}))if(o.toLowerCase().replace(/^\./,"")===r)return l;return null}async add(e){if(this.view==="button"){const s=this.items.filter(b=>b.status==="done"||b.status==="error");s.forEach(y),this.items=this.items.filter(b=>!s.includes(b))}const r=this.maxFiles>0?this.maxFiles:Number.POSITIVE_INFINITY,o=[...this.items],l=o.length,g=[];let i="";for(const s of Array.from(e)){if(o.length>=r){i=x(this.msg.errTooMany,{max:r});break}if(this.accept&&!Fe(this.accept,s.name,s.type)){i=x(this.msg.errType,{name:s.name});continue}const b=this.ruleFor(s.name),h=ae((b==null?void 0:b.maxSize)??this.maxSize),m=ae((b==null?void 0:b.minSize)??this.minSize);if(h&&s.size>h){i=x(this.msg.errTooLarge,{name:s.name,size:Z(h)});continue}if(m&&s.size<m){i=x(this.msg.errTooSmall,{name:s.name,size:Z(m)});continue}const v=De(s);if(o.some(re=>re.key===v)){i=x(this.msg.errDuplicate,{name:s.name});continue}const X={key:v,file:s,name:s.name,status:this.needsInspection(b,s.name)?"checking":"ready",percent:0,error:"",record:null,pages:null,encrypted:null,preview:qe(s)};o.push(X),g.push(X)}this.notice=i,i&&this.emit("singlebase-upload-rejected",{message:i}),o.length!==l&&(this.items=o,this.emit("singlebase-upload-selected",{files:this.items}),await Promise.all(g.filter(s=>s.status==="checking").map(s=>this.inspect(s,this.ruleFor(s.file.name)))),(this.autoUpload||this.view==="button")&&this.upload())}needsInspection(e,r){return!e||!Ue(Q(r))?!1:e.maxPages!==void 0||e.allowProtected===!1}async inspect(e,r){const o=await ze(e.file,Q(e.file.name));e.pages=o.pages,e.encrypted=o.encrypted;let l="";r.allowProtected===!1&&o.encrypted===!0?l=x(this.msg.errProtected,{name:e.name}):r.maxPages&&o.pages!==null&&o.pages>r.maxPages&&(l=x(this.msg.errTooManyPages,{name:e.name,pages:o.pages,max:r.maxPages})),l?(y(e),this.items=this.items.filter(g=>g!==e),this.notice=l,this.emit("singlebase-upload-rejected",{message:l})):(e.status="ready",this.items=[...this.items])}removeItem(e){this.items.filter(r=>r.key===e).forEach(y),this.items=this.items.filter(r=>r.key!==e),this.notice=""}commitRename(e,r){e.name=je(e.file.name,r),this.editing="",this.items=[...this.items]}fail(e){var r;this.notice=e,this.emit("singlebase-upload-error",{message:e}),(r=this.onError)==null||r.call(this,{message:e})}emit(e,r){this.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0,composed:!0}))}redirect(){if(!this.redirectUrl||typeof location>"u")return;const e=ve(this.redirectUrl,location.href,r=>console.warn(`[singlebase-uploader] ${r}`));e&&location.assign(e)}onPick(e){var o;const r=e.target;(o=r.files)!=null&&o.length&&this.add(r.files),r.value=""}onDrop(e){var o;e.preventDefault(),this.dragging=!1;const r=(o=e.dataTransfer)==null?void 0:o.files;r!=null&&r.length&&this.add(r)}onDragOver(e){e.preventDefault(),this.dragging=!0}onDragLeave(){this.dragging=!1}get canAddMore(){return this.maxFiles<=0||this.items.length<this.maxFiles}get checking(){return this.items.some(e=>e.status==="checking")}get pendingCount(){return this.items.filter(e=>e.status==="ready"||e.status==="error").length}get hint(){const e=Oe(this.accept),r=ae(this.maxSize),o=r?x(this.msg.hintUpTo,{size:Z(r)}):"";return[e,o].filter(Boolean).join(" · ")}renderInput(){return n.html`<input
977
+ `;function he(r,a,e){if(!r||!a)return null;let t;try{t=new URL(a)}catch{return null}let i;try{i=new URL(r,t.href)}catch{return e==null||e(`"${r}" is not a valid URL`),null}return i.protocol!=="http:"&&i.protocol!=="https:"?(e==null||e(`refusing redirect to unsupported scheme "${i.protocol}"`),null):i.origin!==t.origin?(e==null||e(`refusing cross-origin redirect to ${i.origin}; same-origin only`),null):i.href===t.href?null:i.href}const me={pages:null,encrypted:null},ue=16*1024*1024,$e=2*1024*1024,Se=40,Me=4*1024*1024,xe=new Set(["docx","pptx","xlsx"]);async function ve(r,a){try{if(a==="pdf")return await Ce(r);if(xe.has(a))return await je(r,a)}catch{}return me}function ye(r){return r==="pdf"||xe.has(r)}async function Ce(r){const a=await te(r.slice(0,ue)),e=r.size>ue?await te(r.slice(Math.max(0,r.size-$e))):null,t=re(a)+(e?re(e):""),i=/\/Encrypt[\s/<>\]]/.test(t);let g=we(t);return g===null&&(g=await Te(a)),{pages:g,encrypted:i}}function we(r){if(/\/Type\s*\/Pages/.test(r)){let e=0;for(const t of r.matchAll(/\/Count\s+(\d+)/g))e=Math.max(e,Number(t[1]));if(e>0)return e}const a=r.match(/\/Type\s*\/Page[^s]/g);return a!=null&&a.length?a.length:null}async function Te(r){if(typeof DecompressionStream>"u")return null;const a=re(r);let e="",t=0;for(const i of a.matchAll(/stream\r?\n/g)){if(t>=Se||e.length>=Me)break;const g=i.index+i[0].length;let m=a.indexOf("endstream",g);if(m<0)break;for(;m>g&&(a[m-1]===`
978
+ `||a[m-1]==="\r");)m-=1;t+=1;try{const o=await ke(r.subarray(g,m),"deflate");e+=re(o)}catch{}}return e?we(e):null}async function je(r,a){const e=await te(r.slice(0,8));if(Ee(e))return{pages:null,encrypted:!0};if(e[0]!==80||e[1]!==75)return me;const t=await Fe(r,"docProps/app.xml");if(!t)return{pages:null,encrypted:!1};const i=a==="pptx"?"Slides":"Pages",g=new TextDecoder().decode(t).match(new RegExp(`<${i}>(\\d+)</${i}>`));return{pages:g?Number(g[1]):null,encrypted:!1}}function Ee(r){return[208,207,17,224,161,177,26,225].every((e,t)=>r[t]===e)}async function Fe(r,a){const e=Math.min(r.size,66e3),t=new DataView(await r.slice(r.size-e).arrayBuffer());let i=-1;for(let h=t.byteLength-22;h>=0;h--)if(t.getUint32(h,!0)===101010256){i=h;break}if(i<0)return null;const g=t.getUint32(i+12,!0),m=t.getUint32(i+16,!0);if(!g||m===4294967295)return null;const o=new DataView(await r.slice(m,m+g).arrayBuffer()),n=new TextDecoder;let b=0;for(;b+46<=o.byteLength&&o.getUint32(b,!0)===33639248;){const h=o.getUint16(b+10,!0),x=o.getUint32(b+20,!0),v=o.getUint16(b+28,!0),ee=o.getUint16(b+30,!0),ie=o.getUint16(b+32,!0),ae=o.getUint32(b+42,!0);if(n.decode(new Uint8Array(o.buffer,o.byteOffset+b+46,v))===a){const ne=new DataView(await r.slice(ae,ae+30).arrayBuffer()),le=ae+30+ne.getUint16(26,!0)+ne.getUint16(28,!0),de=await te(r.slice(le,le+x));return h===0?de:h===8&&typeof DecompressionStream<"u"?await ke(de,"deflate-raw"):null}b+=46+v+ee+ie}return null}async function te(r){return new Uint8Array(await r.arrayBuffer())}async function ke(r,a){const e=new Blob([r]).stream().pipeThrough(new DecompressionStream(a));return new Uint8Array(await new Response(e).arrayBuffer())}function re(r){let a="";for(let t=0;t<r.length;t+=32768)a+=String.fromCharCode(...r.subarray(t,t+32768));return a}var ze=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,De=(r,a,e)=>a in r?ze(r,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[a]=e,u=(r,a,e,t)=>{for(var i=t>1?void 0:t?Oe(a,e):a,g=r.length-1,m;g>=0;g--)(m=r[g])&&(i=(t?m(a,e,i):m(i))||i);return t&&i&&ze(a,e,i),i},Le=(r,a,e)=>De(r,a+"",e);const se={fromAttribute:r=>{if(!r)return{};try{const a=JSON.parse(r);return a&&typeof a=="object"?a:{}}catch{return console.warn("[singlebase-uploader] an attribute holds invalid JSON; ignoring it"),{}}},toAttribute:r=>JSON.stringify(r??{})},oe={fromAttribute:r=>r===null?!0:r!=="false",toAttribute:r=>r?null:"false"},fe=["view","dropzone","allowRename","autoUpload","branding","brandingText","brandingUrl","logoUrl","logoText","heading","description","maxFiles","maxSize","minSize","accept","rules","bucket","publicRead","redirectUrl","metadata","options","messages","theme","density","radius","onComplete","onError"];var w,k,z,U,$,S,M,C,T,j,E,F,O,D,L,A,N,P,R,B,I,G,_,q,K,V,Y,H,J,X,W,Z,Q,ge;exports.SinglebaseUploader=(ge=class extends s.LitElement{constructor(){super(...arguments);d(this,w,null);d(this,k,{});d(this,z);d(this,U);d(this,$);d(this,S,"full");d(this,M,!0);d(this,C,!0);d(this,T,!1);d(this,j,!0);d(this,E,"");d(this,F,"");d(this,O,"");d(this,D,"");d(this,L,"");d(this,A,"");d(this,N,10);d(this,P,"25MB");d(this,R,0);d(this,B,"");d(this,I,{});d(this,G,"default");d(this,_,{});d(this,q,{});d(this,K,!1);d(this,V,"");d(this,Y,null);d(this,H,null);d(this,J,[]);d(this,X,"");d(this,W,!1);d(this,Z,!1);d(this,Q,"")}get client(){return l(this,w)}set client(e){c(this,w,e)}get messages(){return l(this,k)}set messages(e){c(this,k,e)}get theme(){return l(this,z)}set theme(e){c(this,z,e)}get density(){return l(this,U)}set density(e){c(this,U,e)}get radius(){return l(this,$)}set radius(e){c(this,$,e)}get view(){return l(this,S)}set view(e){c(this,S,e)}get dropzone(){return l(this,M)}set dropzone(e){c(this,M,e)}get allowRename(){return l(this,C)}set allowRename(e){c(this,C,e)}get autoUpload(){return l(this,T)}set autoUpload(e){c(this,T,e)}get branding(){return l(this,j)}set branding(e){c(this,j,e)}get brandingText(){return l(this,E)}set brandingText(e){c(this,E,e)}get brandingUrl(){return l(this,F)}set brandingUrl(e){c(this,F,e)}get logoUrl(){return l(this,O)}set logoUrl(e){c(this,O,e)}get logoText(){return l(this,D)}set logoText(e){c(this,D,e)}get heading(){return l(this,L)}set heading(e){c(this,L,e)}get description(){return l(this,A)}set description(e){c(this,A,e)}get maxFiles(){return l(this,N)}set maxFiles(e){c(this,N,e)}get maxSize(){return l(this,P)}set maxSize(e){c(this,P,e)}get minSize(){return l(this,R)}set minSize(e){c(this,R,e)}get accept(){return l(this,B)}set accept(e){c(this,B,e)}get rules(){return l(this,I)}set rules(e){c(this,I,e)}get bucket(){return l(this,G)}set bucket(e){c(this,G,e)}get metadata(){return l(this,_)}set metadata(e){c(this,_,e)}get options(){return l(this,q)}set options(e){c(this,q,e)}get publicRead(){return l(this,K)}set publicRead(e){c(this,K,e)}get redirectUrl(){return l(this,V)}set redirectUrl(e){c(this,V,e)}get onComplete(){return l(this,Y)}set onComplete(e){c(this,Y,e)}get onError(){return l(this,H)}set onError(e){c(this,H,e)}get items(){return l(this,J)}set items(e){c(this,J,e)}get notice(){return l(this,X)}set notice(e){c(this,X,e)}get busy(){return l(this,W)}set busy(e){c(this,W,e)}get dragging(){return l(this,Z)}set dragging(e){c(this,Z,e)}get editing(){return l(this,Q)}set editing(e){c(this,Q,e)}get msg(){return f.resolveUploadMessages(this.messages)}get resolvedClient(){return this.client??Ue.getDefaultClient()??null}get files(){return this.items}get percent(){const e=this.items.filter(t=>t.status!=="ready");return e.length?Math.round(e.reduce((t,i)=>t+i.percent,0)/e.length):0}open(){var e;(e=this.renderRoot.querySelector("input[type=file]"))==null||e.click()}set config(e){const t=this;for(const i of fe)e&&i in e&&(t[i]=e[i])}configure(e){return this.config=e,this}get config(){const e=this;return Object.fromEntries(fe.map(t=>[t,e[t]]))}clear(){this.items.forEach(y),this.items=[],this.notice=""}disconnectedCallback(){super.disconnectedCallback(),this.items.forEach(y)}async upload(){var m;if(this.busy)return;const e=this.items.filter(o=>o.status==="ready"||o.status==="error");if(!e.length)return;const t=this.resolvedClient;if(!t){this.fail(this.msg.errNoClient);return}this.busy=!0,this.notice="";for(const o of e)o.status="uploading",o.percent=0,o.error="";this.items=[...this.items];const i=new Map,g=e.map(o=>{const n={file:o.file,filename:o.file.name};return this.bucket&&(n.bucket=this.bucket),this.publicRead&&(n.publicRead=!0),o.name!==o.file.name&&(n.newName=o.name),Object.keys(this.metadata??{}).length&&(n.metadata={...this.metadata}),Object.keys(this.options??{}).length&&(n.options={...this.options}),i.set(n,o),n});try{const o=await t.files.upload(g,{onProgress:h=>{const x=i.get(h.input);x&&(x.percent=h.percent,this.items=[...this.items],this.emit("singlebase-upload-progress",{file:x,percent:this.percent}))}});for(const h of o.completed){const x=i.get(h.input);x&&(x.status="done",x.percent=100,x.record=h.file)}for(const h of o.failed){const x=i.get(h.input);x&&(x.status="error",x.error=h.error.message||h.error.code)}this.items=[...this.items];const n=o.completed.map(h=>i.get(h.input)).filter(Boolean),b=o.failed.map(h=>i.get(h.input)).filter(Boolean);this.emit("singlebase-upload-complete",{completed:n,failed:b}),(m=this.onComplete)==null||m.call(this,{completed:n,failed:b}),b.length?this.notice=this.msg.errUpload:this.redirect()}catch(o){for(const n of e)n.status="error",n.error="";this.items=[...this.items],this.fail(Ne(o)||this.msg.errUpload)}finally{this.busy=!1}}ruleFor(e){const t=f.fileExtension(e);if(!t)return null;for(const[i,g]of Object.entries(this.rules??{}))if(i.toLowerCase().replace(/^\./,"")===t)return g;return null}async add(e){if(this.view==="button"){const n=this.items.filter(b=>b.status==="done"||b.status==="error");n.forEach(y),this.items=this.items.filter(b=>!n.includes(b))}const t=this.maxFiles>0?this.maxFiles:Number.POSITIVE_INFINITY,i=[...this.items],g=i.length,m=[];let o="";for(const n of Array.from(e)){if(i.length>=t){o=f.fill(this.msg.errTooMany,{max:t});break}if(this.accept&&!f.acceptsFile(this.accept,n.name,n.type)){o=f.fill(this.msg.errType,{name:n.name});continue}const b=this.ruleFor(n.name),h=f.parseSize((b==null?void 0:b.maxSize)??this.maxSize),x=f.parseSize((b==null?void 0:b.minSize)??this.minSize);if(h&&n.size>h){o=f.fill(this.msg.errTooLarge,{name:n.name,size:f.formatSize(h)});continue}if(x&&n.size<x){o=f.fill(this.msg.errTooSmall,{name:n.name,size:f.formatSize(x)});continue}const v=f.fileKey(n);if(i.some(ie=>ie.key===v)){o=f.fill(this.msg.errDuplicate,{name:n.name});continue}const ee={key:v,file:n,name:n.name,status:this.needsInspection(b,n.name)?"checking":"ready",percent:0,error:"",record:null,pages:null,encrypted:null,preview:Ae(n)};i.push(ee),m.push(ee)}this.notice=o,o&&this.emit("singlebase-upload-rejected",{message:o}),i.length!==g&&(this.items=i,this.emit("singlebase-upload-selected",{files:this.items}),await Promise.all(m.filter(n=>n.status==="checking").map(n=>this.inspect(n,this.ruleFor(n.file.name)))),(this.autoUpload||this.view==="button")&&this.upload())}needsInspection(e,t){return!e||!ye(f.fileExtension(t))?!1:e.maxPages!==void 0||e.allowProtected===!1}async inspect(e,t){const i=await ve(e.file,f.fileExtension(e.file.name));e.pages=i.pages,e.encrypted=i.encrypted;let g="";t.allowProtected===!1&&i.encrypted===!0?g=f.fill(this.msg.errProtected,{name:e.name}):t.maxPages&&i.pages!==null&&i.pages>t.maxPages&&(g=f.fill(this.msg.errTooManyPages,{name:e.name,pages:i.pages,max:t.maxPages})),g?(y(e),this.items=this.items.filter(m=>m!==e),this.notice=g,this.emit("singlebase-upload-rejected",{message:g})):(e.status="ready",this.items=[...this.items])}removeItem(e){this.items.filter(t=>t.key===e).forEach(y),this.items=this.items.filter(t=>t.key!==e),this.notice=""}commitRename(e,t){e.name=f.renameKeepingExtension(e.file.name,t),this.editing="",this.items=[...this.items]}fail(e){var t;this.notice=e,this.emit("singlebase-upload-error",{message:e}),(t=this.onError)==null||t.call(this,{message:e})}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}redirect(){if(!this.redirectUrl||typeof location>"u")return;const e=he(this.redirectUrl,location.href,t=>console.warn(`[singlebase-uploader] ${t}`));e&&location.assign(e)}onPick(e){var i;const t=e.target;(i=t.files)!=null&&i.length&&this.add(t.files),t.value=""}onDrop(e){var i;e.preventDefault(),this.dragging=!1;const t=(i=e.dataTransfer)==null?void 0:i.files;t!=null&&t.length&&this.add(t)}onDragOver(e){e.preventDefault(),this.dragging=!0}onDragLeave(){this.dragging=!1}get canAddMore(){return this.maxFiles<=0||this.items.length<this.maxFiles}get checking(){return this.items.some(e=>e.status==="checking")}get pendingCount(){return this.items.filter(e=>e.status==="ready"||e.status==="error").length}get hint(){const e=f.acceptSummary(this.accept),t=f.parseSize(this.maxSize),i=t?f.fill(this.msg.hintUpTo,{size:f.formatSize(t)}):"";return[e,i].filter(Boolean).join(" · ")}renderInput(){return s.html`<input
1015
979
  class="sr-only"
1016
980
  type="file"
1017
981
  ?multiple=${this.maxFiles!==1}
1018
- accept=${this.accept||n.nothing}
982
+ accept=${this.accept||s.nothing}
1019
983
  @change=${this.onPick}
1020
- />`}renderLogo(){return this.logoUrl?n.html`<img
984
+ />`}renderLogo(){return this.logoUrl?s.html`<img
1021
985
  class="logo-img"
1022
986
  src=${this.logoUrl}
1023
987
  alt=${this.logoText||"Logo"}
1024
988
  part="logo"
1025
- />`:this.logoText?n.html`<div class="brand-mark" part="logo">${this.logoText}</div>`:n.nothing}renderBranding(){return this.branding?n.html`<div class="branding" part="branding">
1026
- <a href="https://singlebase.cloud" target="_blank" rel="noopener noreferrer"
1027
- >${this.msg.brandingLabel}</a
1028
- >
1029
- </div>`:n.nothing}renderNotice(){return this.notice?n.html`<div class="banner" role="alert" part="error">${this.notice}</div>`:n.nothing}renderCount(){if(!this.items.length)return n.nothing;const e=this.items.length===1?this.msg.countOne:this.msg.countMany;return n.html`<div class="count" part="count">
1030
- ${x(e,{n:this.items.length,max:this.maxFiles})}
1031
- </div>`}renderStatus(e){const r=Z(e.file.size);if(e.status==="checking")return`${r} · ${this.msg.checking}`;if(e.status==="uploading")return`${r} · ${this.msg.uploading}`;if(e.status==="done")return`${r} · ${this.msg.uploaded}`;if(e.status==="error")return`${r} · ${e.error||this.msg.failedLabel}`;const o=e.pages?` · ${x(this.msg.pagesLabel,{n:e.pages})}`:"";return r+o}renderRow(e){const r=this.allowRename&&e.status==="ready";return e.status==="uploading"||e.status,n.html`<div class="row" part="file">
989
+ />`:this.logoText?s.html`<div class="brand-mark" part="logo">${this.logoText}</div>`:s.nothing}renderBranding(){return f.renderBranding(this.branding,this.brandingText,this.msg.brandingLabel,this.brandingUrl)}renderNotice(){return this.notice?s.html`<div class="banner" role="alert" part="error">${this.notice}</div>`:s.nothing}renderCount(){if(!this.items.length)return s.nothing;const e=this.items.length===1?this.msg.countOne:this.msg.countMany;return s.html`<div class="count" part="count">
990
+ ${f.fill(e,{n:this.items.length,max:this.maxFiles})}
991
+ </div>`}renderStatus(e){const t=f.formatSize(e.file.size);if(e.status==="checking")return`${t} · ${this.msg.checking}`;if(e.status==="uploading")return`${t} · ${this.msg.uploading}`;if(e.status==="done")return`${t} · ${this.msg.uploaded}`;if(e.status==="error")return`${t} · ${e.error||this.msg.failedLabel}`;const i=e.pages?` · ${f.fill(this.msg.pagesLabel,{n:e.pages})}`:"";return t+i}renderRow(e){const t=this.allowRename&&e.status==="ready";return e.status==="uploading"||e.status,s.html`<div class="row" part="file">
1032
992
  <div class="chip" part="file-type">
1033
- ${e.preview?n.html`<img class="thumb" src=${e.preview} alt="" part="preview" />`:Le(e.name)||"FILE"}
993
+ ${e.preview?s.html`<img class="thumb" src=${e.preview} alt="" part="preview" />`:f.extensionOf(e.name)||"FILE"}
1034
994
  </div>
1035
995
  <div class="meta">
1036
- ${this.editing===e.key?n.html`<input
996
+ ${this.editing===e.key?s.html`<input
1037
997
  class="name-input"
1038
998
  .value=${e.name}
1039
999
  autofocus
1040
- @keydown=${o=>{o.key==="Enter"?this.commitRename(e,o.target.value):o.key==="Escape"&&(this.editing="")}}
1041
- @blur=${o=>this.commitRename(e,o.target.value)}
1042
- />`:r?n.html`<button
1000
+ @keydown=${i=>{i.key==="Enter"?this.commitRename(e,i.target.value):i.key==="Escape"&&(this.editing="")}}
1001
+ @blur=${i=>this.commitRename(e,i.target.value)}
1002
+ />`:t?s.html`<button
1043
1003
  class="name"
1044
1004
  title=${this.msg.rename}
1045
1005
  @click=${()=>{this.editing=e.key}}
1046
1006
  >
1047
1007
  ${e.name}
1048
- </button>`:n.html`<div class="name">${e.name}</div>`}
1008
+ </button>`:s.html`<div class="name">${e.name}</div>`}
1049
1009
  <div class="sz" data-state=${e.status}>${this.renderStatus(e)}</div>
1050
- ${e.status==="uploading"?n.html`<div class="bar" part="progress">
1010
+ ${e.status==="uploading"?s.html`<div class="bar" part="progress">
1051
1011
  <div class="bar-fill" style="width:${e.percent}%"></div>
1052
- </div>`:n.nothing}
1012
+ </div>`:s.nothing}
1053
1013
  </div>
1054
1014
  <div class="row-act">
1055
- ${e.status==="error"?n.html`<button class="link-sm" @click=${()=>void this.upload()}>
1015
+ ${e.status==="error"?s.html`<button class="link-sm" @click=${()=>void this.upload()}>
1056
1016
  ${this.msg.retry}
1057
- </button>`:n.nothing}
1058
- ${e.status==="uploading"||e.status==="done"?n.nothing:n.html`<button class="link-sm" @click=${()=>this.removeItem(e.key)}>
1017
+ </button>`:s.nothing}
1018
+ ${e.status==="uploading"||e.status==="done"?s.nothing:s.html`<button class="link-sm" @click=${()=>this.removeItem(e.key)}>
1059
1019
  ${this.msg.remove}
1060
1020
  </button>`}
1061
1021
  </div>
1062
- </div>`}renderRows(){return this.items.length?n.html`<div class="rows" part="files">
1022
+ </div>`}renderRows(){return this.items.length?s.html`<div class="rows" part="files">
1063
1023
  ${this.items.map(e=>this.renderRow(e))}
1064
- </div>`:n.nothing}renderDropzone(){return n.html`<div class="drop" part="dropzone" data-drag=${String(this.dragging)}>
1024
+ </div>`:s.nothing}renderDropzone(){return s.html`<div class="drop" part="dropzone" data-drag=${String(this.dragging)}>
1065
1025
  <div class="arrow" aria-hidden="true">↑</div>
1066
1026
  <div class="drop-title">${this.msg.dropTitle}</div>
1067
1027
  <button class="link" @click=${this.open}>${this.msg.dropSub}</button>
1068
- ${this.hint?n.html`<div class="hint">${this.hint}</div>`:n.nothing}
1069
- </div>`}renderUploadCta(){const e=this.pendingCount;if(this.autoUpload||!e&&!this.busy)return n.nothing;const r=e===1?this.msg.uploadCtaOne:this.msg.uploadCtaMany;return n.html`<button
1028
+ ${this.hint?s.html`<div class="hint">${this.hint}</div>`:s.nothing}
1029
+ </div>`}renderUploadCta(){const e=this.pendingCount;if(this.autoUpload||!e&&!this.busy)return s.nothing;const t=e===1?this.msg.uploadCtaOne:this.msg.uploadCtaMany;return s.html`<button
1070
1030
  class="primary wide"
1071
1031
  part="submit"
1072
1032
  ?disabled=${this.busy||this.checking}
1073
1033
  @click=${()=>void this.upload()}
1074
1034
  >
1075
- ${this.busy?this.msg.uploading:x(r,{n:e})}
1076
- </button>`}renderFull(){const e=this.dropzone&&!this.items.length&&this.canAddMore;return n.html`<div
1035
+ ${this.busy?this.msg.uploading:f.fill(t,{n:e})}
1036
+ </button>`}renderFull(){const e=this.dropzone&&!this.items.length&&this.canAddMore;return s.html`<div
1077
1037
  class="card"
1078
1038
  part="card"
1079
1039
  @dragover=${this.onDragOver}
1080
1040
  @dragleave=${this.onDragLeave}
1081
1041
  @drop=${this.onDrop}
1082
1042
  >
1083
- ${this.logoUrl||this.logoText||this.heading||this.description?n.html`<div class="head-block">
1043
+ ${this.logoUrl||this.logoText||this.heading||this.description?s.html`<div class="head-block">
1084
1044
  ${this.renderLogo()}
1085
- ${this.heading?n.html`<div class="title">${this.heading}</div>`:n.nothing}
1086
- ${this.description?n.html`<div class="sub">${this.description}</div>`:n.nothing}
1087
- </div>`:n.nothing}
1045
+ ${this.heading?s.html`<div class="title">${this.heading}</div>`:s.nothing}
1046
+ ${this.description?s.html`<div class="sub">${this.description}</div>`:s.nothing}
1047
+ </div>`:s.nothing}
1088
1048
  ${this.renderCount()} ${this.renderNotice()} ${this.renderRows()}
1089
- ${e?this.renderDropzone():n.nothing}
1090
- ${!e&&this.canAddMore?n.html`<button class="add-more" @click=${this.open}>${this.msg.addMore}</button>`:n.nothing}
1049
+ ${e?this.renderDropzone():s.nothing}
1050
+ ${!e&&this.canAddMore?s.html`<button class="add-more" @click=${this.open}>${this.msg.addMore}</button>`:s.nothing}
1091
1051
  ${this.renderUploadCta()} ${this.renderBranding()}
1092
- </div>`}renderCompact(){return n.html`<div
1052
+ </div>`}renderCompact(){return s.html`<div
1093
1053
  class="card"
1094
1054
  part="card"
1095
1055
  @dragover=${this.onDragOver}
@@ -1100,23 +1060,23 @@
1100
1060
  <span class="sec-title">${this.heading||this.msg.attachments}</span>
1101
1061
  <span class="count">${this.items.length} / ${this.maxFiles}</span>
1102
1062
  </div>
1103
- ${this.dropzone?n.html`<div class="strip" part="dropzone" data-drag=${String(this.dragging)}>
1063
+ ${this.dropzone?s.html`<div class="strip" part="dropzone" data-drag=${String(this.dragging)}>
1104
1064
  <span class="strip-label">${this.msg.dropOrChoose}</span>
1105
1065
  <button class="secondary" ?disabled=${!this.canAddMore} @click=${this.open}>
1106
1066
  ${this.msg.chooseFiles}
1107
1067
  </button>
1108
- </div>`:n.html`<button class="secondary" ?disabled=${!this.canAddMore} @click=${this.open}>
1068
+ </div>`:s.html`<button class="secondary" ?disabled=${!this.canAddMore} @click=${this.open}>
1109
1069
  ${this.msg.chooseFiles}
1110
1070
  </button>`}
1111
- ${this.hint?n.html`<div class="hint">${this.hint}</div>`:n.nothing} ${this.renderNotice()}
1071
+ ${this.hint?s.html`<div class="hint">${this.hint}</div>`:s.nothing} ${this.renderNotice()}
1112
1072
  ${this.renderRows()} ${this.renderUploadCta()} ${this.renderBranding()}
1113
- </div>`}renderButton(){const e=this.items[this.items.length-1];return n.html`<div class="button-view">
1073
+ </div>`}renderButton(){const e=this.items[this.items.length-1];return s.html`<div class="button-view">
1114
1074
  <button class="primary" ?disabled=${this.busy||!this.canAddMore} @click=${this.open}>
1115
1075
  ${this.busy?this.msg.uploading:this.msg.chooseFile}
1116
1076
  </button>
1117
- ${e&&e.status!=="ready"?n.html`<div class="sz" data-state=${e.status}>${this.renderStatus(e)}</div>`:n.nothing}
1077
+ ${e&&e.status!=="ready"?s.html`<div class="sz" data-state=${e.status}>${this.renderStatus(e)}</div>`:s.nothing}
1118
1078
  ${this.renderNotice()}
1119
- </div>`}render(){return n.html`${this.renderInput()}${this.view==="button"?this.renderButton():this.view==="compact"?this.renderCompact():this.renderFull()}`}},w=new WeakMap,k=new WeakMap,z=new WeakMap,U=new WeakMap,$=new WeakMap,S=new WeakMap,C=new WeakMap,M=new WeakMap,T=new WeakMap,L=new WeakMap,F=new WeakMap,O=new WeakMap,D=new WeakMap,j=new WeakMap,A=new WeakMap,E=new WeakMap,N=new WeakMap,B=new WeakMap,P=new WeakMap,R=new WeakMap,I=new WeakMap,G=new WeakMap,_=new WeakMap,K=new WeakMap,W=new WeakMap,q=new WeakMap,Y=new WeakMap,H=new WeakMap,V=new WeakMap,J=new WeakMap,he);We(exports.SinglebaseUploader,"styles",[me,xe,n.css`
1079
+ </div>`}render(){return s.html`${this.renderInput()}${this.view==="button"?this.renderButton():this.view==="compact"?this.renderCompact():this.renderFull()}`}},w=new WeakMap,k=new WeakMap,z=new WeakMap,U=new WeakMap,$=new WeakMap,S=new WeakMap,M=new WeakMap,C=new WeakMap,T=new WeakMap,j=new WeakMap,E=new WeakMap,F=new WeakMap,O=new WeakMap,D=new WeakMap,L=new WeakMap,A=new WeakMap,N=new WeakMap,P=new WeakMap,R=new WeakMap,B=new WeakMap,I=new WeakMap,G=new WeakMap,_=new WeakMap,q=new WeakMap,K=new WeakMap,V=new WeakMap,Y=new WeakMap,H=new WeakMap,J=new WeakMap,X=new WeakMap,W=new WeakMap,Z=new WeakMap,Q=new WeakMap,ge);Le(exports.SinglebaseUploader,"styles",[f.tokenDefaults,be,f.brandingStyles,s.css`
1120
1080
  .card {
1121
1081
  display: flex;
1122
1082
  flex-direction: column;
@@ -1126,7 +1086,7 @@
1126
1086
  background: var(--sb-surface, #ffffff);
1127
1087
  color: var(--sb-ink, #16181a);
1128
1088
  border: 1px solid var(--sb-border, #e4e6e9);
1129
- border-radius: calc(var(--sb-radius, 4px) + 4px);
1089
+ border-radius: calc((var(--sb-radius, 4px) + 4px) * var(--sb-radius-scale, 1));
1130
1090
  }
1131
1091
 
1132
1092
  .logo-img {
@@ -1168,7 +1128,7 @@
1168
1128
  padding: 30px 20px;
1169
1129
  text-align: center;
1170
1130
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
1171
- border-radius: calc(var(--sb-radius, 4px) + 2px);
1131
+ border-radius: calc((var(--sb-radius, 4px) + 2px) * var(--sb-radius-scale, 1));
1172
1132
  background: var(--sb-surface, #ffffff);
1173
1133
  transition:
1174
1134
  border-color 0.15s,
@@ -1208,7 +1168,7 @@
1208
1168
  gap: 12px;
1209
1169
  padding: 10px 12px;
1210
1170
  border: 1px solid var(--sb-border, #e4e6e9);
1211
- border-radius: calc(var(--sb-radius, 4px) + 2px);
1171
+ border-radius: calc((var(--sb-radius, 4px) + 2px) * var(--sb-radius-scale, 1));
1212
1172
  background: var(--sb-surface-alt, #fafafa);
1213
1173
  transition:
1214
1174
  border-color 0.15s,
@@ -1255,7 +1215,7 @@
1255
1215
  color: var(--sb-muted-ink, #61666c);
1256
1216
  background: var(--sb-surface-alt, #fafafa);
1257
1217
  border: 1px solid var(--sb-border, #e4e6e9);
1258
- border-radius: var(--sb-radius, 4px);
1218
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
1259
1219
  overflow: hidden;
1260
1220
  }
1261
1221
 
@@ -1344,7 +1304,7 @@
1344
1304
  color: var(--sb-ink, #16181a);
1345
1305
  background: none;
1346
1306
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
1347
- border-radius: calc(var(--sb-radius, 4px) + 2px);
1307
+ border-radius: calc((var(--sb-radius, 4px) + 2px) * var(--sb-radius-scale, 1));
1348
1308
  }
1349
1309
 
1350
1310
  button.add-more:hover:not(:disabled) {
@@ -1357,25 +1317,6 @@
1357
1317
  font-size: 14px;
1358
1318
  }
1359
1319
 
1360
- .branding {
1361
- text-align: center;
1362
- font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
1363
- font-size: 10.5px;
1364
- letter-spacing: 0.06em;
1365
- color: var(--sb-muted-ink, #61666c);
1366
- }
1367
-
1368
- .branding a {
1369
- color: inherit;
1370
- text-decoration: none;
1371
- }
1372
-
1373
- .branding a:hover {
1374
- color: var(--sb-ink, #16181a);
1375
- text-decoration: underline;
1376
- text-underline-offset: 3px;
1377
- }
1378
-
1379
1320
  /* the button view is just a control, not a card */
1380
1321
  :host([view="button"]) {
1381
1322
  display: inline-block;
@@ -1386,5 +1327,5 @@
1386
1327
  flex-direction: column;
1387
1328
  gap: 8px;
1388
1329
  }
1389
- `]);f([u.property({attribute:!1})],exports.SinglebaseUploader.prototype,"client",1);f([u.property({attribute:!1})],exports.SinglebaseUploader.prototype,"messages",1);f([u.property({reflect:!0})],exports.SinglebaseUploader.prototype,"theme",1);f([u.property({reflect:!0})],exports.SinglebaseUploader.prototype,"density",1);f([u.property({reflect:!0})],exports.SinglebaseUploader.prototype,"view",1);f([u.property({converter:le})],exports.SinglebaseUploader.prototype,"dropzone",1);f([u.property({converter:le,attribute:"allow-rename"})],exports.SinglebaseUploader.prototype,"allowRename",1);f([u.property({type:Boolean,attribute:"auto-upload"})],exports.SinglebaseUploader.prototype,"autoUpload",1);f([u.property({converter:le})],exports.SinglebaseUploader.prototype,"branding",1);f([u.property({attribute:"logo-url"})],exports.SinglebaseUploader.prototype,"logoUrl",1);f([u.property({attribute:"logo-text"})],exports.SinglebaseUploader.prototype,"logoText",1);f([u.property()],exports.SinglebaseUploader.prototype,"heading",1);f([u.property()],exports.SinglebaseUploader.prototype,"description",1);f([u.property({type:Number,attribute:"max-files"})],exports.SinglebaseUploader.prototype,"maxFiles",1);f([u.property({attribute:"max-size"})],exports.SinglebaseUploader.prototype,"maxSize",1);f([u.property({attribute:"min-size"})],exports.SinglebaseUploader.prototype,"minSize",1);f([u.property()],exports.SinglebaseUploader.prototype,"accept",1);f([u.property({converter:se})],exports.SinglebaseUploader.prototype,"rules",1);f([u.property()],exports.SinglebaseUploader.prototype,"bucket",1);f([u.property({converter:se})],exports.SinglebaseUploader.prototype,"metadata",1);f([u.property({converter:se})],exports.SinglebaseUploader.prototype,"options",1);f([u.property({type:Boolean,attribute:"public-read"})],exports.SinglebaseUploader.prototype,"publicRead",1);f([u.property({attribute:"redirect-url"})],exports.SinglebaseUploader.prototype,"redirectUrl",1);f([u.property({attribute:!1})],exports.SinglebaseUploader.prototype,"onComplete",1);f([u.property({attribute:!1})],exports.SinglebaseUploader.prototype,"onError",1);f([u.state()],exports.SinglebaseUploader.prototype,"items",1);f([u.state()],exports.SinglebaseUploader.prototype,"notice",1);f([u.state()],exports.SinglebaseUploader.prototype,"busy",1);f([u.state()],exports.SinglebaseUploader.prototype,"dragging",1);f([u.state()],exports.SinglebaseUploader.prototype,"editing",1);exports.SinglebaseUploader=f([u.customElement("singlebase-uploader")],exports.SinglebaseUploader);function qe(t){return!t.type.startsWith("image/")||typeof URL.createObjectURL!="function"?"":URL.createObjectURL(t)}function y(t){t.preview&&URL.revokeObjectURL(t.preview)}function Ye(t){return t instanceof Error?t.message:""}exports.TOKEN_DEFAULTS=ne;exports.defaultUploadMessages=ie;exports.inspectFile=ze;exports.isInspectable=Ue;exports.resolveRedirectTarget=ve;exports.resolveUploadMessages=ye;exports.sharedStyles=xe;exports.tokenDefaults=me;
1390
- //# sourceMappingURL=uploader-eFYKpk8b.cjs.map
1330
+ `]);u([p.property({attribute:!1})],exports.SinglebaseUploader.prototype,"client",1);u([p.property({attribute:!1})],exports.SinglebaseUploader.prototype,"messages",1);u([p.property({reflect:!0})],exports.SinglebaseUploader.prototype,"theme",1);u([p.property({reflect:!0})],exports.SinglebaseUploader.prototype,"density",1);u([p.property({reflect:!0})],exports.SinglebaseUploader.prototype,"radius",1);u([p.property({reflect:!0})],exports.SinglebaseUploader.prototype,"view",1);u([p.property({converter:oe})],exports.SinglebaseUploader.prototype,"dropzone",1);u([p.property({converter:oe,attribute:"allow-rename"})],exports.SinglebaseUploader.prototype,"allowRename",1);u([p.property({type:Boolean,attribute:"auto-upload"})],exports.SinglebaseUploader.prototype,"autoUpload",1);u([p.property({converter:oe})],exports.SinglebaseUploader.prototype,"branding",1);u([p.property({attribute:"branding-text"})],exports.SinglebaseUploader.prototype,"brandingText",1);u([p.property({attribute:"branding-url"})],exports.SinglebaseUploader.prototype,"brandingUrl",1);u([p.property({attribute:"logo-url"})],exports.SinglebaseUploader.prototype,"logoUrl",1);u([p.property({attribute:"logo-text"})],exports.SinglebaseUploader.prototype,"logoText",1);u([p.property()],exports.SinglebaseUploader.prototype,"heading",1);u([p.property()],exports.SinglebaseUploader.prototype,"description",1);u([p.property({type:Number,attribute:"max-files"})],exports.SinglebaseUploader.prototype,"maxFiles",1);u([p.property({attribute:"max-size"})],exports.SinglebaseUploader.prototype,"maxSize",1);u([p.property({attribute:"min-size"})],exports.SinglebaseUploader.prototype,"minSize",1);u([p.property()],exports.SinglebaseUploader.prototype,"accept",1);u([p.property({converter:se})],exports.SinglebaseUploader.prototype,"rules",1);u([p.property()],exports.SinglebaseUploader.prototype,"bucket",1);u([p.property({converter:se})],exports.SinglebaseUploader.prototype,"metadata",1);u([p.property({converter:se})],exports.SinglebaseUploader.prototype,"options",1);u([p.property({type:Boolean,attribute:"public-read"})],exports.SinglebaseUploader.prototype,"publicRead",1);u([p.property({attribute:"redirect-url"})],exports.SinglebaseUploader.prototype,"redirectUrl",1);u([p.property({attribute:!1})],exports.SinglebaseUploader.prototype,"onComplete",1);u([p.property({attribute:!1})],exports.SinglebaseUploader.prototype,"onError",1);u([p.state()],exports.SinglebaseUploader.prototype,"items",1);u([p.state()],exports.SinglebaseUploader.prototype,"notice",1);u([p.state()],exports.SinglebaseUploader.prototype,"busy",1);u([p.state()],exports.SinglebaseUploader.prototype,"dragging",1);u([p.state()],exports.SinglebaseUploader.prototype,"editing",1);exports.SinglebaseUploader=u([p.customElement("singlebase-uploader")],exports.SinglebaseUploader);function Ae(r){return!r.type.startsWith("image/")||typeof URL.createObjectURL!="function"?"":URL.createObjectURL(r)}function y(r){r.preview&&URL.revokeObjectURL(r.preview)}function Ne(r){return r instanceof Error?r.message:""}exports.inspectFile=ve;exports.isInspectable=ye;exports.resolveRedirectTarget=he;exports.sharedStyles=be;
1331
+ //# sourceMappingURL=uploader-660JIgIN.cjs.map