@singlebase/elements 0.5.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 (50) hide show
  1. package/dist/{authui-display-BCZBP7HR.js → authui-display-CKfGK5va.js} +519 -503
  2. package/dist/authui-display-CKfGK5va.js.map +1 -0
  3. package/dist/{authui-display-CLGFSqRi.cjs → authui-display-aWNht0cW.cjs} +38 -58
  4. package/dist/authui-display-aWNht0cW.cjs.map +1 -0
  5. package/dist/authui.cjs +1 -1
  6. package/dist/authui.js +2 -2
  7. package/dist/chat-C-gsskho.cjs +3258 -0
  8. package/dist/chat-C-gsskho.cjs.map +1 -0
  9. package/dist/{chat-bXaRWel7.js → chat-CEh6RygY.js} +1957 -1137
  10. package/dist/chat-CEh6RygY.js.map +1 -0
  11. package/dist/chat-messages.d.ts +11 -5
  12. package/dist/chat.cjs +1 -1
  13. package/dist/chat.d.ts +4 -3
  14. package/dist/chat.js +8 -6
  15. package/dist/elements/authui-base.d.ts +2 -0
  16. package/dist/elements/authui-buttons.d.ts +1 -1
  17. package/dist/elements/authui-display.d.ts +1 -1
  18. package/dist/elements/authui.d.ts +5 -1
  19. package/dist/elements/chat.d.ts +153 -10
  20. package/dist/elements/uploader.d.ts +14 -0
  21. package/dist/{files-BOwtpYyQ.js → files-DDJWPzZW.js} +82 -35
  22. package/dist/files-DDJWPzZW.js.map +1 -0
  23. package/dist/files-DyxcjZsx.cjs +75 -0
  24. package/dist/files-DyxcjZsx.cjs.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +24 -22
  27. package/dist/singlebase-elements.min.js +3799 -2892
  28. package/dist/singlebase-elements.min.js.map +1 -1
  29. package/dist/styles/branding.d.ts +5 -0
  30. package/dist/styles/tokens.d.ts +2 -0
  31. package/dist/{uploader-DGV2y9uT.cjs → uploader-660JIgIN.cjs} +53 -76
  32. package/dist/uploader-660JIgIN.cjs.map +1 -0
  33. package/dist/{uploader-abQoem5q.js → uploader-vfczkX51.js} +294 -271
  34. package/dist/uploader-vfczkX51.js.map +1 -0
  35. package/dist/uploader.cjs +1 -1
  36. package/dist/uploader.js +2 -2
  37. package/dist/utils/branding.d.ts +8 -0
  38. package/dist/utils/markdown.d.ts +69 -12
  39. package/dist/utils/svg.d.ts +10 -0
  40. package/package.json +3 -3
  41. package/dist/authui-display-BCZBP7HR.js.map +0 -1
  42. package/dist/authui-display-CLGFSqRi.cjs.map +0 -1
  43. package/dist/chat-DRenTJlI.cjs +0 -3001
  44. package/dist/chat-DRenTJlI.cjs.map +0 -1
  45. package/dist/chat-bXaRWel7.js.map +0 -1
  46. package/dist/files-BOwtpYyQ.js.map +0 -1
  47. package/dist/files-DW8A4Jl-.cjs +0 -38
  48. package/dist/files-DW8A4Jl-.cjs.map +0 -1
  49. package/dist/uploader-DGV2y9uT.cjs.map +0 -1
  50. package/dist/uploader-abQoem5q.js.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;
@@ -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";
@@ -1,4 +1,4 @@
1
- "use strict";var se=r=>{throw TypeError(r)};var le=(r,o,e)=>o.has(r)||se("Cannot "+e);var l=(r,o,e)=>(le(r,o,"read from private field"),e?e.call(r):o.get(r)),d=(r,o,e)=>o.has(r)?se("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,e),c=(r,o,e,t)=>(le(r,o,"write to private field"),t?t.call(r,e):o.set(r,e),e);const a=require("lit"),p=require("lit/decorators.js"),we=require("@singlebase/core"),g=require("./files-DW8A4Jl-.cjs"),ue=a.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`
2
2
  /* ── layout primitives ───────────────────────────────────── */
3
3
  .stack {
4
4
  display: flex;
@@ -122,7 +122,7 @@
122
122
  color: var(--sb-ink, #16181a);
123
123
  background: var(--sb-surface-alt, #fafafa);
124
124
  border: 1px solid var(--sb-border, #e4e6e9);
125
- border-radius: var(--sb-radius, 4px);
125
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
126
126
  padding: var(--sb-field-pad, 11px 13px);
127
127
  outline: none;
128
128
  }
@@ -192,7 +192,7 @@
192
192
  font: inherit;
193
193
  font-size: 13.5px;
194
194
  font-weight: 500;
195
- border-radius: var(--sb-radius, 4px);
195
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
196
196
  cursor: pointer;
197
197
  padding: 9px 14px;
198
198
  border: 1px solid transparent;
@@ -368,7 +368,7 @@
368
368
  .notice {
369
369
  font-size: 13px;
370
370
  line-height: 1.45;
371
- border-radius: var(--sb-radius, 4px);
371
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
372
372
  padding: 10px 12px;
373
373
  }
374
374
 
@@ -486,7 +486,7 @@
486
486
 
487
487
  .acc-item {
488
488
  border: 1px solid var(--sb-border, #e4e6e9);
489
- border-radius: var(--sb-radius, 4px);
489
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
490
490
  overflow: hidden;
491
491
  background: transparent;
492
492
  transition:
@@ -601,7 +601,7 @@
601
601
  padding: 10px 12px;
602
602
  background: var(--sb-surface-alt, #fafafa);
603
603
  border: 1px solid var(--sb-border, #e4e6e9);
604
- border-radius: var(--sb-radius, 4px);
604
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
605
605
  }
606
606
 
607
607
  .invite-label {
@@ -768,7 +768,7 @@
768
768
  padding: 14px;
769
769
  background: var(--sb-surface-alt, #fafafa);
770
770
  border: 1px solid var(--sb-border, #e4e6e9);
771
- border-radius: var(--sb-radius, 4px);
771
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
772
772
  }
773
773
 
774
774
  /* 2FA switch */
@@ -817,7 +817,7 @@
817
817
  flex: 0 0 auto;
818
818
  width: 74px;
819
819
  height: 74px;
820
- border-radius: var(--sb-radius, 4px);
820
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
821
821
  background: var(--sb-surface-alt, #fafafa);
822
822
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
823
823
  display: flex;
@@ -849,7 +849,7 @@
849
849
  gap: 12px;
850
850
  padding: 10px 12px;
851
851
  border: 1px solid var(--sb-border, #e4e6e9);
852
- border-radius: var(--sb-radius, 4px);
852
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
853
853
  background: var(--sb-surface-alt, #fafafa);
854
854
  }
855
855
 
@@ -913,7 +913,7 @@
913
913
  font: inherit;
914
914
  text-align: left;
915
915
  padding: 10px 11px;
916
- border-radius: var(--sb-radius, 4px);
916
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
917
917
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
918
918
  background: transparent;
919
919
  cursor: pointer;
@@ -965,7 +965,7 @@
965
965
  gap: 12px;
966
966
  padding: 14px;
967
967
  border: 1px solid var(--sb-danger-panel-border, #efd9d6);
968
- border-radius: var(--sb-radius, 4px);
968
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
969
969
  background: var(--sb-danger-panel-bg, #fdf7f6);
970
970
  }
971
971
 
@@ -974,86 +974,82 @@
974
974
  color: var(--sb-muted-ink, #61666c);
975
975
  font-style: italic;
976
976
  }
977
- `;function fe(r,o,e){if(!r||!o)return null;let t;try{t=new URL(o)}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 ge={pages:null,encrypted:null},de=16*1024*1024,ke=2*1024*1024,ze=40,$e=4*1024*1024,be=new Set(["docx","pptx","xlsx"]);async function he(r,o){try{if(o==="pdf")return await Ue(r);if(be.has(o))return await Me(r,o)}catch{}return ge}function me(r){return r==="pdf"||be.has(r)}async function Ue(r){const o=await Z(r.slice(0,de)),e=r.size>de?await Z(r.slice(Math.max(0,r.size-ke))):null,t=Q(o)+(e?Q(e):""),i=/\/Encrypt[\s/<>\]]/.test(t);let f=xe(t);return f===null&&(f=await Se(o)),{pages:f,encrypted:i}}function xe(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 o=r.match(/\/Type\s*\/Page[^s]/g);return o!=null&&o.length?o.length:null}async function Se(r){if(typeof DecompressionStream>"u")return null;const o=Q(r);let e="",t=0;for(const i of o.matchAll(/stream\r?\n/g)){if(t>=ze||e.length>=$e)break;const f=i.index+i[0].length;let m=o.indexOf("endstream",f);if(m<0)break;for(;m>f&&(o[m-1]===`
978
- `||o[m-1]==="\r");)m-=1;t+=1;try{const n=await ve(r.subarray(f,m),"deflate");e+=Q(n)}catch{}}return e?xe(e):null}async function Me(r,o){const e=await Z(r.slice(0,8));if(Ce(e))return{pages:null,encrypted:!0};if(e[0]!==80||e[1]!==75)return ge;const t=await je(r,"docProps/app.xml");if(!t)return{pages:null,encrypted:!1};const i=o==="pptx"?"Slides":"Pages",f=new TextDecoder().decode(t).match(new RegExp(`<${i}>(\\d+)</${i}>`));return{pages:f?Number(f[1]):null,encrypted:!1}}function Ce(r){return[208,207,17,224,161,177,26,225].every((e,t)=>r[t]===e)}async function je(r,o){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 f=t.getUint32(i+12,!0),m=t.getUint32(i+16,!0);if(!f||m===4294967295)return null;const n=new DataView(await r.slice(m,m+f).arrayBuffer()),s=new TextDecoder;let b=0;for(;b+46<=n.byteLength&&n.getUint32(b,!0)===33639248;){const h=n.getUint16(b+10,!0),x=n.getUint32(b+20,!0),v=n.getUint16(b+28,!0),W=n.getUint16(b+30,!0),ee=n.getUint16(b+32,!0),te=n.getUint32(b+42,!0);if(s.decode(new Uint8Array(n.buffer,n.byteOffset+b+46,v))===o){const oe=new DataView(await r.slice(te,te+30).arrayBuffer()),ae=te+30+oe.getUint16(26,!0)+oe.getUint16(28,!0),ne=await Z(r.slice(ae,ae+x));return h===0?ne:h===8&&typeof DecompressionStream<"u"?await ve(ne,"deflate-raw"):null}b+=46+v+W+ee}return null}async function Z(r){return new Uint8Array(await r.arrayBuffer())}async function ve(r,o){const e=new Blob([r]).stream().pipeThrough(new DecompressionStream(o));return new Uint8Array(await new Response(e).arrayBuffer())}function Q(r){let o="";for(let t=0;t<r.length;t+=32768)o+=String.fromCharCode(...r.subarray(t,t+32768));return o}var ye=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Fe=(r,o,e)=>o in r?ye(r,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[o]=e,u=(r,o,e,t)=>{for(var i=t>1?void 0:t?Ee(o,e):o,f=r.length-1,m;f>=0;f--)(m=r[f])&&(i=(t?m(o,e,i):m(i))||i);return t&&i&&ye(o,e,i),i},Oe=(r,o,e)=>Fe(r,o+"",e);const re={fromAttribute:r=>{if(!r)return{};try{const o=JSON.parse(r);return o&&typeof o=="object"?o:{}}catch{return console.warn("[singlebase-uploader] an attribute holds invalid JSON; ignoring it"),{}}},toAttribute:r=>JSON.stringify(r??{})},ie={fromAttribute:r=>r===null?!0:r!=="false",toAttribute:r=>r?null:"false"},ce=["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,M,C,j,E,F,O,D,L,T,A,N,P,R,G,I,B,_,q,K,V,Y,H,J,X,pe;exports.SinglebaseUploader=(pe=class extends a.LitElement{constructor(){super(...arguments);d(this,w,null);d(this,k,{});d(this,z);d(this,$);d(this,U,"full");d(this,S,!0);d(this,M,!0);d(this,C,!1);d(this,j,!0);d(this,E,"");d(this,F,"");d(this,O,"");d(this,D,"");d(this,L,10);d(this,T,"25MB");d(this,A,0);d(this,N,"");d(this,P,{});d(this,R,"default");d(this,G,{});d(this,I,{});d(this,B,!1);d(this,_,"");d(this,q,null);d(this,K,null);d(this,V,[]);d(this,Y,"");d(this,H,!1);d(this,J,!1);d(this,X,"")}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,$)}set density(e){c(this,$,e)}get view(){return l(this,U)}set view(e){c(this,U,e)}get dropzone(){return l(this,S)}set dropzone(e){c(this,S,e)}get allowRename(){return l(this,M)}set allowRename(e){c(this,M,e)}get autoUpload(){return l(this,C)}set autoUpload(e){c(this,C,e)}get branding(){return l(this,j)}set branding(e){c(this,j,e)}get logoUrl(){return l(this,E)}set logoUrl(e){c(this,E,e)}get logoText(){return l(this,F)}set logoText(e){c(this,F,e)}get heading(){return l(this,O)}set heading(e){c(this,O,e)}get description(){return l(this,D)}set description(e){c(this,D,e)}get maxFiles(){return l(this,L)}set maxFiles(e){c(this,L,e)}get maxSize(){return l(this,T)}set maxSize(e){c(this,T,e)}get minSize(){return l(this,A)}set minSize(e){c(this,A,e)}get accept(){return l(this,N)}set accept(e){c(this,N,e)}get rules(){return l(this,P)}set rules(e){c(this,P,e)}get bucket(){return l(this,R)}set bucket(e){c(this,R,e)}get metadata(){return l(this,G)}set metadata(e){c(this,G,e)}get options(){return l(this,I)}set options(e){c(this,I,e)}get publicRead(){return l(this,B)}set publicRead(e){c(this,B,e)}get redirectUrl(){return l(this,_)}set redirectUrl(e){c(this,_,e)}get onComplete(){return l(this,q)}set onComplete(e){c(this,q,e)}get onError(){return l(this,K)}set onError(e){c(this,K,e)}get items(){return l(this,V)}set items(e){c(this,V,e)}get notice(){return l(this,Y)}set notice(e){c(this,Y,e)}get busy(){return l(this,H)}set busy(e){c(this,H,e)}get dragging(){return l(this,J)}set dragging(e){c(this,J,e)}get editing(){return l(this,X)}set editing(e){c(this,X,e)}get msg(){return g.resolveUploadMessages(this.messages)}get resolvedClient(){return this.client??we.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 ce)e&&i in e&&(t[i]=e[i])}get config(){const e=this;return Object.fromEntries(ce.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(n=>n.status==="ready"||n.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 n of e)n.status="uploading",n.percent=0,n.error="";this.items=[...this.items];const i=new Map,f=e.map(n=>{const s={file:n.file,filename:n.file.name};return this.bucket&&(s.bucket=this.bucket),this.publicRead&&(s.publicRead=!0),n.name!==n.file.name&&(s.newName=n.name),Object.keys(this.metadata??{}).length&&(s.metadata={...this.metadata}),Object.keys(this.options??{}).length&&(s.options={...this.options}),i.set(s,n),s});try{const n=await t.files.upload(f,{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 n.completed){const x=i.get(h.input);x&&(x.status="done",x.percent=100,x.record=h.file)}for(const h of n.failed){const x=i.get(h.input);x&&(x.status="error",x.error=h.error.message||h.error.code)}this.items=[...this.items];const s=n.completed.map(h=>i.get(h.input)).filter(Boolean),b=n.failed.map(h=>i.get(h.input)).filter(Boolean);this.emit("singlebase-upload-complete",{completed:s,failed:b}),(m=this.onComplete)==null||m.call(this,{completed:s,failed:b}),b.length?this.notice=this.msg.errUpload:this.redirect()}catch(n){for(const s of e)s.status="error",s.error="";this.items=[...this.items],this.fail(Le(n)||this.msg.errUpload)}finally{this.busy=!1}}ruleFor(e){const t=g.fileExtension(e);if(!t)return null;for(const[i,f]of Object.entries(this.rules??{}))if(i.toLowerCase().replace(/^\./,"")===t)return f;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 t=this.maxFiles>0?this.maxFiles:Number.POSITIVE_INFINITY,i=[...this.items],f=i.length,m=[];let n="";for(const s of Array.from(e)){if(i.length>=t){n=g.fill(this.msg.errTooMany,{max:t});break}if(this.accept&&!g.acceptsFile(this.accept,s.name,s.type)){n=g.fill(this.msg.errType,{name:s.name});continue}const b=this.ruleFor(s.name),h=g.parseSize((b==null?void 0:b.maxSize)??this.maxSize),x=g.parseSize((b==null?void 0:b.minSize)??this.minSize);if(h&&s.size>h){n=g.fill(this.msg.errTooLarge,{name:s.name,size:g.formatSize(h)});continue}if(x&&s.size<x){n=g.fill(this.msg.errTooSmall,{name:s.name,size:g.formatSize(x)});continue}const v=g.fileKey(s);if(i.some(ee=>ee.key===v)){n=g.fill(this.msg.errDuplicate,{name:s.name});continue}const W={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:De(s)};i.push(W),m.push(W)}this.notice=n,n&&this.emit("singlebase-upload-rejected",{message:n}),i.length!==f&&(this.items=i,this.emit("singlebase-upload-selected",{files:this.items}),await Promise.all(m.filter(s=>s.status==="checking").map(s=>this.inspect(s,this.ruleFor(s.file.name)))),(this.autoUpload||this.view==="button")&&this.upload())}needsInspection(e,t){return!e||!me(g.fileExtension(t))?!1:e.maxPages!==void 0||e.allowProtected===!1}async inspect(e,t){const i=await he(e.file,g.fileExtension(e.file.name));e.pages=i.pages,e.encrypted=i.encrypted;let f="";t.allowProtected===!1&&i.encrypted===!0?f=g.fill(this.msg.errProtected,{name:e.name}):t.maxPages&&i.pages!==null&&i.pages>t.maxPages&&(f=g.fill(this.msg.errTooManyPages,{name:e.name,pages:i.pages,max:t.maxPages})),f?(y(e),this.items=this.items.filter(m=>m!==e),this.notice=f,this.emit("singlebase-upload-rejected",{message:f})):(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=g.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=fe(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=g.acceptSummary(this.accept),t=g.parseSize(this.maxSize),i=t?g.fill(this.msg.hintUpTo,{size:g.formatSize(t)}):"";return[e,i].filter(Boolean).join(" · ")}renderInput(){return a.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
979
979
  class="sr-only"
980
980
  type="file"
981
981
  ?multiple=${this.maxFiles!==1}
982
- accept=${this.accept||a.nothing}
982
+ accept=${this.accept||s.nothing}
983
983
  @change=${this.onPick}
984
- />`}renderLogo(){return this.logoUrl?a.html`<img
984
+ />`}renderLogo(){return this.logoUrl?s.html`<img
985
985
  class="logo-img"
986
986
  src=${this.logoUrl}
987
987
  alt=${this.logoText||"Logo"}
988
988
  part="logo"
989
- />`:this.logoText?a.html`<div class="brand-mark" part="logo">${this.logoText}</div>`:a.nothing}renderBranding(){return this.branding?a.html`<div class="branding" part="branding">
990
- <a href="https://singlebase.cloud" target="_blank" rel="noopener noreferrer"
991
- >${this.msg.brandingLabel}</a
992
- >
993
- </div>`:a.nothing}renderNotice(){return this.notice?a.html`<div class="banner" role="alert" part="error">${this.notice}</div>`:a.nothing}renderCount(){if(!this.items.length)return a.nothing;const e=this.items.length===1?this.msg.countOne:this.msg.countMany;return a.html`<div class="count" part="count">
994
- ${g.fill(e,{n:this.items.length,max:this.maxFiles})}
995
- </div>`}renderStatus(e){const t=g.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?` · ${g.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,a.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">
996
992
  <div class="chip" part="file-type">
997
- ${e.preview?a.html`<img class="thumb" src=${e.preview} alt="" part="preview" />`:g.extensionOf(e.name)||"FILE"}
993
+ ${e.preview?s.html`<img class="thumb" src=${e.preview} alt="" part="preview" />`:f.extensionOf(e.name)||"FILE"}
998
994
  </div>
999
995
  <div class="meta">
1000
- ${this.editing===e.key?a.html`<input
996
+ ${this.editing===e.key?s.html`<input
1001
997
  class="name-input"
1002
998
  .value=${e.name}
1003
999
  autofocus
1004
1000
  @keydown=${i=>{i.key==="Enter"?this.commitRename(e,i.target.value):i.key==="Escape"&&(this.editing="")}}
1005
1001
  @blur=${i=>this.commitRename(e,i.target.value)}
1006
- />`:t?a.html`<button
1002
+ />`:t?s.html`<button
1007
1003
  class="name"
1008
1004
  title=${this.msg.rename}
1009
1005
  @click=${()=>{this.editing=e.key}}
1010
1006
  >
1011
1007
  ${e.name}
1012
- </button>`:a.html`<div class="name">${e.name}</div>`}
1008
+ </button>`:s.html`<div class="name">${e.name}</div>`}
1013
1009
  <div class="sz" data-state=${e.status}>${this.renderStatus(e)}</div>
1014
- ${e.status==="uploading"?a.html`<div class="bar" part="progress">
1010
+ ${e.status==="uploading"?s.html`<div class="bar" part="progress">
1015
1011
  <div class="bar-fill" style="width:${e.percent}%"></div>
1016
- </div>`:a.nothing}
1012
+ </div>`:s.nothing}
1017
1013
  </div>
1018
1014
  <div class="row-act">
1019
- ${e.status==="error"?a.html`<button class="link-sm" @click=${()=>void this.upload()}>
1015
+ ${e.status==="error"?s.html`<button class="link-sm" @click=${()=>void this.upload()}>
1020
1016
  ${this.msg.retry}
1021
- </button>`:a.nothing}
1022
- ${e.status==="uploading"||e.status==="done"?a.nothing:a.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)}>
1023
1019
  ${this.msg.remove}
1024
1020
  </button>`}
1025
1021
  </div>
1026
- </div>`}renderRows(){return this.items.length?a.html`<div class="rows" part="files">
1022
+ </div>`}renderRows(){return this.items.length?s.html`<div class="rows" part="files">
1027
1023
  ${this.items.map(e=>this.renderRow(e))}
1028
- </div>`:a.nothing}renderDropzone(){return a.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)}>
1029
1025
  <div class="arrow" aria-hidden="true">↑</div>
1030
1026
  <div class="drop-title">${this.msg.dropTitle}</div>
1031
1027
  <button class="link" @click=${this.open}>${this.msg.dropSub}</button>
1032
- ${this.hint?a.html`<div class="hint">${this.hint}</div>`:a.nothing}
1033
- </div>`}renderUploadCta(){const e=this.pendingCount;if(this.autoUpload||!e&&!this.busy)return a.nothing;const t=e===1?this.msg.uploadCtaOne:this.msg.uploadCtaMany;return a.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
1034
1030
  class="primary wide"
1035
1031
  part="submit"
1036
1032
  ?disabled=${this.busy||this.checking}
1037
1033
  @click=${()=>void this.upload()}
1038
1034
  >
1039
- ${this.busy?this.msg.uploading:g.fill(t,{n:e})}
1040
- </button>`}renderFull(){const e=this.dropzone&&!this.items.length&&this.canAddMore;return a.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
1041
1037
  class="card"
1042
1038
  part="card"
1043
1039
  @dragover=${this.onDragOver}
1044
1040
  @dragleave=${this.onDragLeave}
1045
1041
  @drop=${this.onDrop}
1046
1042
  >
1047
- ${this.logoUrl||this.logoText||this.heading||this.description?a.html`<div class="head-block">
1043
+ ${this.logoUrl||this.logoText||this.heading||this.description?s.html`<div class="head-block">
1048
1044
  ${this.renderLogo()}
1049
- ${this.heading?a.html`<div class="title">${this.heading}</div>`:a.nothing}
1050
- ${this.description?a.html`<div class="sub">${this.description}</div>`:a.nothing}
1051
- </div>`:a.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}
1052
1048
  ${this.renderCount()} ${this.renderNotice()} ${this.renderRows()}
1053
- ${e?this.renderDropzone():a.nothing}
1054
- ${!e&&this.canAddMore?a.html`<button class="add-more" @click=${this.open}>${this.msg.addMore}</button>`:a.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}
1055
1051
  ${this.renderUploadCta()} ${this.renderBranding()}
1056
- </div>`}renderCompact(){return a.html`<div
1052
+ </div>`}renderCompact(){return s.html`<div
1057
1053
  class="card"
1058
1054
  part="card"
1059
1055
  @dragover=${this.onDragOver}
@@ -1064,23 +1060,23 @@
1064
1060
  <span class="sec-title">${this.heading||this.msg.attachments}</span>
1065
1061
  <span class="count">${this.items.length} / ${this.maxFiles}</span>
1066
1062
  </div>
1067
- ${this.dropzone?a.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)}>
1068
1064
  <span class="strip-label">${this.msg.dropOrChoose}</span>
1069
1065
  <button class="secondary" ?disabled=${!this.canAddMore} @click=${this.open}>
1070
1066
  ${this.msg.chooseFiles}
1071
1067
  </button>
1072
- </div>`:a.html`<button class="secondary" ?disabled=${!this.canAddMore} @click=${this.open}>
1068
+ </div>`:s.html`<button class="secondary" ?disabled=${!this.canAddMore} @click=${this.open}>
1073
1069
  ${this.msg.chooseFiles}
1074
1070
  </button>`}
1075
- ${this.hint?a.html`<div class="hint">${this.hint}</div>`:a.nothing} ${this.renderNotice()}
1071
+ ${this.hint?s.html`<div class="hint">${this.hint}</div>`:s.nothing} ${this.renderNotice()}
1076
1072
  ${this.renderRows()} ${this.renderUploadCta()} ${this.renderBranding()}
1077
- </div>`}renderButton(){const e=this.items[this.items.length-1];return a.html`<div class="button-view">
1073
+ </div>`}renderButton(){const e=this.items[this.items.length-1];return s.html`<div class="button-view">
1078
1074
  <button class="primary" ?disabled=${this.busy||!this.canAddMore} @click=${this.open}>
1079
1075
  ${this.busy?this.msg.uploading:this.msg.chooseFile}
1080
1076
  </button>
1081
- ${e&&e.status!=="ready"?a.html`<div class="sz" data-state=${e.status}>${this.renderStatus(e)}</div>`:a.nothing}
1077
+ ${e&&e.status!=="ready"?s.html`<div class="sz" data-state=${e.status}>${this.renderStatus(e)}</div>`:s.nothing}
1082
1078
  ${this.renderNotice()}
1083
- </div>`}render(){return a.html`${this.renderInput()}${this.view==="button"?this.renderButton():this.view==="compact"?this.renderCompact():this.renderFull()}`}},w=new WeakMap,k=new WeakMap,z=new WeakMap,$=new WeakMap,U=new WeakMap,S=new WeakMap,M=new WeakMap,C=new WeakMap,j=new WeakMap,E=new WeakMap,F=new WeakMap,O=new WeakMap,D=new WeakMap,L=new WeakMap,T=new WeakMap,A=new WeakMap,N=new WeakMap,P=new WeakMap,R=new WeakMap,G=new WeakMap,I=new WeakMap,B=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,pe);Oe(exports.SinglebaseUploader,"styles",[g.tokenDefaults,ue,a.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`
1084
1080
  .card {
1085
1081
  display: flex;
1086
1082
  flex-direction: column;
@@ -1090,7 +1086,7 @@
1090
1086
  background: var(--sb-surface, #ffffff);
1091
1087
  color: var(--sb-ink, #16181a);
1092
1088
  border: 1px solid var(--sb-border, #e4e6e9);
1093
- border-radius: calc(var(--sb-radius, 4px) + 4px);
1089
+ border-radius: calc((var(--sb-radius, 4px) + 4px) * var(--sb-radius-scale, 1));
1094
1090
  }
1095
1091
 
1096
1092
  .logo-img {
@@ -1132,7 +1128,7 @@
1132
1128
  padding: 30px 20px;
1133
1129
  text-align: center;
1134
1130
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
1135
- border-radius: calc(var(--sb-radius, 4px) + 2px);
1131
+ border-radius: calc((var(--sb-radius, 4px) + 2px) * var(--sb-radius-scale, 1));
1136
1132
  background: var(--sb-surface, #ffffff);
1137
1133
  transition:
1138
1134
  border-color 0.15s,
@@ -1172,7 +1168,7 @@
1172
1168
  gap: 12px;
1173
1169
  padding: 10px 12px;
1174
1170
  border: 1px solid var(--sb-border, #e4e6e9);
1175
- border-radius: calc(var(--sb-radius, 4px) + 2px);
1171
+ border-radius: calc((var(--sb-radius, 4px) + 2px) * var(--sb-radius-scale, 1));
1176
1172
  background: var(--sb-surface-alt, #fafafa);
1177
1173
  transition:
1178
1174
  border-color 0.15s,
@@ -1219,7 +1215,7 @@
1219
1215
  color: var(--sb-muted-ink, #61666c);
1220
1216
  background: var(--sb-surface-alt, #fafafa);
1221
1217
  border: 1px solid var(--sb-border, #e4e6e9);
1222
- border-radius: var(--sb-radius, 4px);
1218
+ border-radius: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
1223
1219
  overflow: hidden;
1224
1220
  }
1225
1221
 
@@ -1308,7 +1304,7 @@
1308
1304
  color: var(--sb-ink, #16181a);
1309
1305
  background: none;
1310
1306
  border: 1px dashed var(--sb-border-strong, #cdd1d6);
1311
- border-radius: calc(var(--sb-radius, 4px) + 2px);
1307
+ border-radius: calc((var(--sb-radius, 4px) + 2px) * var(--sb-radius-scale, 1));
1312
1308
  }
1313
1309
 
1314
1310
  button.add-more:hover:not(:disabled) {
@@ -1321,25 +1317,6 @@
1321
1317
  font-size: 14px;
1322
1318
  }
1323
1319
 
1324
- .branding {
1325
- text-align: center;
1326
- font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
1327
- font-size: 10.5px;
1328
- letter-spacing: 0.06em;
1329
- color: var(--sb-muted-ink, #61666c);
1330
- }
1331
-
1332
- .branding a {
1333
- color: inherit;
1334
- text-decoration: none;
1335
- }
1336
-
1337
- .branding a:hover {
1338
- color: var(--sb-ink, #16181a);
1339
- text-decoration: underline;
1340
- text-underline-offset: 3px;
1341
- }
1342
-
1343
1320
  /* the button view is just a control, not a card */
1344
1321
  :host([view="button"]) {
1345
1322
  display: inline-block;
@@ -1350,5 +1327,5 @@
1350
1327
  flex-direction: column;
1351
1328
  gap: 8px;
1352
1329
  }
1353
- `]);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,"view",1);u([p.property({converter:ie})],exports.SinglebaseUploader.prototype,"dropzone",1);u([p.property({converter:ie,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:ie})],exports.SinglebaseUploader.prototype,"branding",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:re})],exports.SinglebaseUploader.prototype,"rules",1);u([p.property()],exports.SinglebaseUploader.prototype,"bucket",1);u([p.property({converter:re})],exports.SinglebaseUploader.prototype,"metadata",1);u([p.property({converter:re})],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 De(r){return!r.type.startsWith("image/")||typeof URL.createObjectURL!="function"?"":URL.createObjectURL(r)}function y(r){r.preview&&URL.revokeObjectURL(r.preview)}function Le(r){return r instanceof Error?r.message:""}exports.inspectFile=he;exports.isInspectable=me;exports.resolveRedirectTarget=fe;exports.sharedStyles=ue;
1354
- //# sourceMappingURL=uploader-DGV2y9uT.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