@wpic/ui 0.8.8 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/COMPONENTS.md +2 -0
- package/dist/components/WPopover.vue.d.ts +2 -0
- package/dist/wpic-ui.cjs +1 -1
- package/dist/wpic-ui.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 0.8.9
|
|
2
|
+
|
|
3
|
+
- WPopover: add `shiftCrossAxis` so preferred-side panels remain inside narrow viewports. Perpendicular overflow is handled by shifting instead of changing sides.
|
|
4
|
+
|
|
1
5
|
## 0.8.8
|
|
2
6
|
|
|
3
7
|
- Add opt-in automatic placement to WPopover: choose among all four sides, adapt to viewport changes, and shift into view before constraining content height. Existing placement behavior is preserved.
|
package/COMPONENTS.md
CHANGED
|
@@ -362,6 +362,8 @@ disabled?: boolean
|
|
|
362
362
|
|
|
363
363
|
Set `autoPlacement` to choose among all four sides with Floating UI. Combine it with `freezePositionOnOpen=false` for panels that must adapt while scrolling or resizing. In this mode, viewport shifting can overlap the anchor when necessary to keep the panel visible; content only scrolls when taller than the viewport. The default placement/flip behavior is unchanged.
|
|
364
364
|
|
|
365
|
+
For a preferred left-side panel, use `placement="left-start"`, `shiftCrossAxis`, and `freezePositionOnOpen=false` (without `autoPlacement`). It flips right when there is insufficient horizontal space and shifts within the viewport, allowing anchor overlap on narrow screens.
|
|
366
|
+
|
|
365
367
|
**Import:** `import { WPopover } from '@wpic/ui'`
|
|
366
368
|
|
|
367
369
|
**Props:**
|
|
@@ -20,6 +20,8 @@ type __VLS_Props = {
|
|
|
20
20
|
flip?: boolean;
|
|
21
21
|
/** Choose the side with most room, allowing overlap when needed to keep content in view. */
|
|
22
22
|
autoPlacement?: boolean;
|
|
23
|
+
/** Shift on both axes to keep a preferred side visible, allowing anchor overlap on small screens. */
|
|
24
|
+
shiftCrossAxis?: boolean;
|
|
23
25
|
zIndex?: string | number;
|
|
24
26
|
/** Extra DOM elements (e.g. Teleport'd submenus) that should not trigger close */
|
|
25
27
|
extraPanels?: (HTMLElement | null)[];
|
package/dist/wpic-ui.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),g=require("lucide-vue-next"),n1=require("@floating-ui/vue"),s0=require("pinia");var A1=typeof document<"u"?document.currentScript:null;const d0={key:0,class:"absolute inset-0 flex items-center justify-center rounded-[inherit]","aria-hidden":"true"},F1=e.defineComponent({__name:"WButton",props:{variant:{},size:{},loading:{type:Boolean},disabled:{type:Boolean},active:{type:Boolean},icon:{type:[Object,Function]},href:{}},emits:["click"],setup(n,{emit:d}){const t=n,o=d;return(s,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.href?"a":"button"),{href:n.href,disabled:n.disabled||n.loading,"data-variant":t.variant??"primary","data-size":t.size??"md","data-active":n.active?"true":void 0,onClick:l[0]||(l[0]=a=>o("click",a)),class:e.normalizeClass(["wpic-button","relative inline-flex items-center justify-center font-medium transition-all duration-150 cursor-pointer select-none","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500/50 focus-visible:ring-offset-1","active:scale-[0.98]",n.disabled||n.loading?"opacity-40 cursor-not-allowed pointer-events-none":"",n.active?"wpic-button--active":"",(t.size??"md")==="sm"?"h-8 touch-manipulation px-2.5 gap-1.5 rounded-md text-sm":"",(t.size??"md")==="md"?(t.variant==="subtle"?"h-11":"h-9")+" px-3.5 gap-2 rounded-lg":"",(t.size??"md")==="lg"?(t.variant==="subtle"?"h-12":"h-11")+" px-4 gap-2 rounded-lg":"",(t.size??"md")==="xs"?"h-5 w-5 p-0 rounded-full text-xs":"",(t.variant??"primary")==="primary"?"wpic-btn-primary text-white":"",(t.variant??"primary")==="secondary"?"bg-zinc-100 hover:bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:hover:bg-zinc-700 dark:text-zinc-200":"",(t.variant??"primary")==="subtle"?"bg-zinc-100 border border-zinc-100 hover:bg-zinc-200/70 text-zinc-700 dark:bg-zinc-800 dark:border-zinc-800 dark:hover:bg-zinc-700 dark:text-zinc-200":"",(t.variant??"primary")==="destructive"?"bg-red-500 hover:bg-red-600 text-white":"",(t.variant??"primary")==="ghost"?"bg-transparent hover:bg-zinc-100 text-zinc-600 hover:text-zinc-900 dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-100":"",(t.variant??"primary")==="outline"?"bg-transparent border border-zinc-200 hover:bg-zinc-50 text-zinc-700 dark:border-zinc-800 dark:hover:bg-zinc-800 dark:text-zinc-300":""])},{default:e.withCtx(()=>[e.createElementVNode("span",{class:e.normalizeClass(["inline-flex items-center justify-center gap-[inherit]",n.loading?"invisible":""])},[n.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.icon),{key:0,size:(t.size??"md")==="xs"?10:(t.size??"md")==="sm"?12:((t.size??"md")==="lg",15)},null,8,["size"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"default")],2),n.loading?(e.openBlock(),e.createElementBlock("span",d0,[e.createVNode(e.unref(g.Loader2),{size:(t.size??"md")==="xs"?10:(t.size??"md")==="sm"?13:(t.size??"md")==="lg"?17:15,class:"animate-spin"},null,8,["size"])])):e.createCommentVNode("",!0)]),_:3},8,["href","disabled","data-variant","data-size","data-active","class"]))}}),u0={class:"wpic-button-group inline-flex"},x2=e.defineComponent({__name:"WButtonGroup",setup(n){return(d,t)=>(e.openBlock(),e.createElementBlock("div",u0,[e.renderSlot(d.$slots,"default")]))}}),m0={class:"wpic-filter flex items-center gap-1"},h0=["onClick"],p0=e.defineComponent({__name:"WFilter",props:{options:{},modelValue:{}},emits:["update:modelValue"],setup(n){return(d,t)=>(e.openBlock(),e.createElementBlock("div",m0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.options,(o,s)=>(e.openBlock(),e.createElementBlock("button",{key:s,type:"button",onClick:l=>d.$emit("update:modelValue",o.value),class:e.normalizeClass(["px-2.5 py-1 text-base font-medium rounded-full transition-all duration-150 cursor-pointer whitespace-nowrap",n.modelValue===o.value?"bg-zinc-100 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 border border-zinc-300 dark:border-zinc-600":"text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300 border border-transparent"])},e.toDisplayString(o.label),11,h0))),128))]))}}),v0={class:"wpic-form-label block mb-1 font-medium text-zinc-600 dark:text-zinc-400"},f0={key:0,class:"ml-0.5",style:{color:"#EF4444"}},a2=e.defineComponent({__name:"WFormLabel",props:{required:{type:Boolean}},setup(n){return(d,t)=>(e.openBlock(),e.createElementBlock("label",v0,[e.renderSlot(d.$slots,"default"),n.required?(e.openBlock(),e.createElementBlock("span",f0,"*")):e.createCommentVNode("",!0)]))}}),g0={class:"relative flex items-center w-full"},C0=["data-size","data-variant","type","placeholder","disabled","required"],k0={key:2,class:"pointer-events-none absolute right-2.5 text-zinc-400 dark:text-zinc-500"},o2=e.defineComponent({inheritAttrs:!1,__name:"WInput",props:e.mergeModels({icon:{type:[Object,Function]},label:{},placeholder:{},required:{type:Boolean},type:{},disabled:{type:Boolean},size:{},clearable:{type:Boolean},loading:{type:Boolean},variant:{},prepend:{},append:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const d=e.useModel(n,"modelValue"),t=n,o=e.useSlots(),s=e.computed(()=>t.prepend!==void 0||!!o.prepend),l=e.computed(()=>t.append!==void 0||!!o.append),a=e.computed(()=>{if(t.icon)return t.icon;if(t.type==="date")return g.Calendar;if(t.type==="money")return g.DollarSign}),m=e.computed(()=>({sm:12,md:13,lg:14,xl:16})[t.size??"md"]),f=e.computed(()=>t.type==="money"?"number":t.type??"text"),h=e.ref(),c=e.ref(),E=e.ref(0);let w;e.watch(c,b=>{w?.disconnect(),E.value=b?.getBoundingClientRect().width??0,b&&(w=new ResizeObserver(()=>{E.value=b.getBoundingClientRect().width}),w.observe(b))},{flush:"post"}),e.onBeforeUnmount(()=>w?.disconnect());function L(){t.type==="date"&&h.value?.showPicker()}if(typeof document<"u"){const b="winput-date-no-picker";if(!document.getElementById(b)){const p=document.createElement("style");p.id=b,p.textContent='input[type="date"]::-webkit-calendar-picker-indicator { display: none; }',document.head.appendChild(p)}const C="winput-number-no-spinner";if(!document.getElementById(C)){const p=document.createElement("style");p.id=C,p.textContent="input.winput-number::-webkit-outer-spin-button, input.winput-number::-webkit-inner-spin-button { display: none; } input.winput-number { -moz-appearance: textfield; }",document.head.appendChild(p)}}return(b,C)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps(b.$attrs,{class:"w-full"}),[t.label?(e.openBlock(),e.createBlock(a2,{key:0,required:t.required},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]),_:1},8,["required"])):e.createCommentVNode("",!0),e.createElementVNode("div",g0,[a.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:0,size:m.value,class:e.normalizeClass(["absolute shrink-0 text-zinc-400 dark:text-zinc-500",[t.size==="xl"?"left-4":"left-2.5",t.type==="date"?"cursor-pointer":"pointer-events-none"]]),onClick:L},null,8,["size","class"])):s.value?(e.openBlock(),e.createElementBlock("span",{key:1,ref_key:"prependRef",ref:c,class:"pointer-events-none absolute left-2.5 text-zinc-400 dark:text-zinc-500"},[e.renderSlot(b.$slots,"prepend",{},()=>[e.createTextVNode(e.toDisplayString(t.prepend),1)])],512)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:h,class:e.normalizeClass(["wpic-control",["w-full rounded-lg outline-none transition-colors",t.size==="sm"?"text-sm":"text-base",f.value==="number"?"winput-number":"",t.size==="sm"?"h-8":t.size==="lg"?"h-11":t.size==="xl"?"h-14":"h-9",a.value||s.value?t.size==="xl"?"pl-11":"pl-9":t.size==="xl"?"pl-4":"pl-2.5",l.value&&(t.clearable&&d.value||t.loading)?"pr-14":l.value?"pr-9":t.clearable&&d.value||t.loading?t.size==="xl"?"pr-10":"pr-7":t.size==="xl"?"pr-4":"pr-2.5",t.disabled?(t.variant??"default")==="subtle"?"bg-zinc-100 dark:bg-zinc-800 border border-zinc-100 dark:border-zinc-800 text-zinc-400 dark:text-zinc-500 cursor-not-allowed opacity-60":"bg-zinc-50 dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-800 text-zinc-400 dark:text-zinc-500 cursor-not-allowed opacity-60":(t.variant??"default")==="subtle"?"bg-zinc-100 dark:bg-zinc-800 border border-zinc-100 dark:border-zinc-800 text-zinc-900 dark:text-zinc-100 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 cursor-text hover:bg-zinc-200/70 dark:hover:bg-zinc-700":"bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 text-zinc-900 dark:text-zinc-100 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 wpic-input-field cursor-text"]]),style:e.normalizeStyle(s.value&&!a.value?{paddingLeft:`calc(${E.value}px + 1.25rem)`}:void 0),"data-size":t.size??"md","data-variant":t.variant??"default","onUpdate:modelValue":C[0]||(C[0]=p=>d.value=p),type:f.value,placeholder:t.placeholder??"",disabled:t.disabled,required:t.required},null,14,C0),[[e.vModelDynamic,d.value]]),l.value?(e.openBlock(),e.createElementBlock("span",k0,[e.renderSlot(b.$slots,"append",{},()=>[e.createTextVNode(e.toDisplayString(t.append),1)])])):e.createCommentVNode("",!0),t.loading?(e.openBlock(),e.createBlock(e.unref(g.Loader2),{key:3,size:t.size==="xl"?14:11,class:e.normalizeClass(["absolute animate-spin text-zinc-400 dark:text-zinc-500",l.value?"right-8":t.size==="xl"?"right-4":"right-2"])},null,8,["size","class"])):t.clearable&&d.value?(e.openBlock(),e.createElementBlock("button",{key:4,type:"button",onClick:C[1]||(C[1]=p=>d.value=""),class:e.normalizeClass(["absolute flex items-center justify-center text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300 transition-colors cursor-pointer",l.value?"right-8":t.size==="xl"?"right-4":"right-2"])},[e.createVNode(e.unref(g.X),{size:t.size==="xl"?14:11},null,8,["size"])],2)):e.createCommentVNode("",!0)])],16))}}),z0=["disabled"],l2=e.defineComponent({__name:"WCheckbox",props:e.mergeModels({disabled:{type:Boolean}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const d=e.useModel(n,"modelValue");return(t,o)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["wpic-checkbox relative inline-flex items-center gap-2 select-none",n.disabled?"cursor-not-allowed opacity-50":"cursor-pointer"])},[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":o[0]||(o[0]=s=>d.value=s),disabled:n.disabled,class:"peer sr-only"},null,8,z0),[[e.vModelCheckbox,d.value]]),e.createElementVNode("span",{class:e.normalizeClass(["wpic-checkbox-box",["flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border transition-all duration-150","peer-focus-visible:ring-2 peer-focus-visible:ring-zinc-400/40 peer-focus-visible:ring-offset-1 peer-focus-visible:ring-offset-white dark:peer-focus-visible:ring-offset-zinc-950",d.value?"border-zinc-900 bg-zinc-900 text-white dark:border-zinc-100 dark:bg-zinc-100 dark:text-zinc-950":"border-zinc-300 bg-white text-transparent shadow-sm hover:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:hover:border-zinc-500"]])},[e.createVNode(e.unref(g.Check),{size:11,"stroke-width":"2.6"})],2),e.renderSlot(t.$slots,"default")],2))}}),O1=e.defineComponent({__name:"WSpinner",props:{size:{default:"md"},tone:{default:"muted"}},setup(n){const d=n,t={sm:"h-4 w-4 border-2",md:"h-5 w-5 border-2",lg:"h-7 w-7 border-[3px]"};return(o,s)=>(e.openBlock(),e.createElementBlock("span",{role:"status","aria-live":"polite","aria-label":"Loading",class:e.normalizeClass(["wpic-spinner","inline-block shrink-0 animate-spin rounded-full border-current border-t-transparent",t[d.size],d.tone==="muted"?"text-zinc-300 dark:text-zinc-700":"text-[var(--wpic-primary,#6366f1)]"])},null,2))}}),b0={key:0,class:"text-zinc-400 dark:text-zinc-500 whitespace-nowrap shrink-0"},y0={key:1,role:"status","aria-live":"polite",class:"flex items-center justify-center py-12 gap-3 text-base text-zinc-400 dark:text-zinc-500"},x0={class:"wpic-table__scroll",style:{"overflow-x":"auto"}},w0={class:"w-full border-collapse"},B0={key:0,style:{width:"36px"}},M0={key:1,style:{width:"32px"}},V0={key:0},E0={class:"wpic-table__header wpic-table__divider border-b border-zinc-100 dark:border-zinc-800"},N0=["onClick"],S0={key:1},L0={key:0,class:"wpic-table__summary wpic-table__divider border-b border-zinc-200 font-medium dark:border-zinc-700"},D0={key:0},F0={key:1},$0=["onClick"],A0=["onClick"],T0={key:0,class:"wpic-table__divider border-b border-zinc-100 dark:border-zinc-800"},H0=["colspan"],P0={key:2},j0=["colspan"],W0={class:"flex flex-col items-center gap-2"},R0={class:"tabular-nums text-zinc-400 dark:text-zinc-500"},I0={key:0,class:"flex items-center gap-0.5"},Z0=["aria-label","disabled"],U0={key:0,class:"w-6 text-center text-base select-none text-zinc-400 dark:text-zinc-500"},K0=["onClick"],O0=["aria-label","disabled"],Y0=e.defineComponent({__name:"WTable",props:{data:{},columns:{},loading:{type:Boolean},loadingSpinner:{type:Boolean,default:!0},labels:{},emptyText:{},pageSize:{},serverTotal:{},serverPage:{},searchPlaceholder:{default:"Search…"},rowClickable:{type:Boolean,default:!1},showHeader:{type:Boolean,default:!0},expandable:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},selectedKeys:{},rowKey:{default:"id"},flushEdges:{type:Boolean,default:!1},rowClass:{},rowStyle:{},summaryRow:{},compact:{type:Boolean},padding:{},showFooter:{type:Boolean,default:!0}},emits:["row-click","update:selectedKeys","row-select","update:serverPage"],setup(n,{expose:d,emit:t}){const o=n,s=t,l=e.ref(new Set);function a(V){l.value.has(V)?l.value.delete(V):l.value.add(V)}const m=e.useSlots(),f=e.computed(()=>o.pageSize??25),h=e.ref(null),c=e.ref("asc");function E(V){h.value===V?c.value=c.value==="asc"?"desc":"asc":(h.value=V,c.value="asc")}const w=e.ref(""),L=e.computed(()=>o.columns.some(V=>V.searchable)),b=e.computed(()=>{let V=o.data??[];const X=w.value.trim().toLowerCase();if(X){const z=o.columns.filter(D=>D.searchable).map(D=>D.field);V=V.filter(D=>z.some(K=>String(D[K]??"").toLowerCase().includes(X)))}if(h.value){const z=h.value;V=[...V].sort((D,K)=>{const e1=D[z]??"",r1=K[z]??"",h1=typeof e1=="number"&&typeof r1=="number"?e1-r1:String(e1).toLowerCase().localeCompare(String(r1).toLowerCase());return c.value==="asc"?h1:-h1})}return V}),C=e.ref(1),p=e.computed(()=>o.serverTotal!==void 0),F=e.computed({get:()=>p.value?o.serverPage??1:C.value,set:V=>{p.value?s("update:serverPage",V):C.value=V}}),q=e.computed(()=>p.value?o.serverTotal??0:b.value.length),t1=e.computed(()=>Math.max(1,Math.ceil(q.value/f.value)));e.watch([w,()=>o.data],()=>{p.value||(F.value=1),l.value.clear()});const P=e.computed(()=>{if(p.value)return b.value;const V=(F.value-1)*f.value;return b.value.slice(V,V+f.value)});function Z(V,X){const z=V[o.rowKey];return typeof z=="string"||typeof z=="number"?z:`${F.value}:${X}`}const M=e.computed(()=>new Set(o.selectedKeys??[])),A=e.computed(()=>P.value.map(Z)),S=e.computed(()=>o.selectable&&A.value.length>0&&A.value.every(V=>M.value.has(V)));function B(V,X,z){const D=Z(V,X),K=new Set(o.selectedKeys??[]),e1=z===!0;e1?K.add(D):K.delete(D),s("update:selectedKeys",[...K]),s("row-select",V,e1)}function U(V){const X=new Set(o.selectedKeys??[]),z=V===!0;for(const D of A.value)z?X.add(D):X.delete(D);s("update:selectedKeys",[...X])}const O=e.computed(()=>q.value===0?0:(F.value-1)*f.value+1),i1=e.computed(()=>Math.min(F.value*f.value,q.value)),j=e.computed(()=>{const V=t1.value;if(V<=7)return Array.from({length:V},(e1,r1)=>r1+1);const X=F.value,z=[],D=new Set([1,V,X-1,X,X+1].filter(e1=>e1>=1&&e1<=V));let K=0;for(const e1 of[...D].sort((r1,h1)=>r1-h1))e1-K>1&&z.push("…"),z.push(e1),K=e1;return z}),J=e.computed(()=>o.padding?`wpic-table--padding-${o.padding}`:o.compact?"wpic-table--padding-sm":"wpic-table--padding-inherit"),W=V=>V==="right"?"text-right":V==="center"?"text-center":"text-left",l1=(V,X)=>[X,o.flushEdges&&V===0&&!o.expandable&&!o.selectable?"pl-0":"wpic-table__pad-l",o.flushEdges&&V===o.columns.length-1?"pr-0":"wpic-table__pad-r"],s1=V=>({...V.width?{width:V.width}:{},...V.minWidth?{minWidth:V.minWidth}:{}});return d({filteredCount:e.computed(()=>b.value.length),searchQuery:w}),(V,X)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wpic-table",J.value])},[(L.value||e.unref(m).toolbar)&&!n.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-2 wpic-table__divider border-b border-zinc-100 dark:border-zinc-800 wpic-table__pad-x",n.compact?"py-1":"py-2"])},[L.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(o2,{modelValue:w.value,"onUpdate:modelValue":X[0]||(X[0]=z=>w.value=z),placeholder:n.searchPlaceholder,icon:e.unref(g.Search),class:"flex-1"},null,8,["modelValue","placeholder","icon"]),w.value?(e.openBlock(),e.createElementBlock("span",b0,e.toDisplayString(b.value.length)+" "+e.toDisplayString(n.labels?.results??"results"),1)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.renderSlot(V.$slots,"toolbar")],2)):e.createCommentVNode("",!0),n.loading?(e.openBlock(),e.createElementBlock("div",y0,[n.loadingSpinner?(e.openBlock(),e.createBlock(O1,{key:0,tone:"muted"})):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(n.labels?.loading??"Loading…"),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",x0,[e.createElementVNode("table",w0,[e.createElementVNode("colgroup",null,[n.selectable?(e.openBlock(),e.createElementBlock("col",B0)):e.createCommentVNode("",!0),n.expandable?(e.openBlock(),e.createElementBlock("col",M0)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,z=>(e.openBlock(),e.createElementBlock("col",{key:z.field,style:e.normalizeStyle(s1(z))},null,4))),128))]),o.showHeader!==!1?(e.openBlock(),e.createElementBlock("thead",V0,[e.createElementVNode("tr",E0,[n.selectable?(e.openBlock(),e.createElementBlock("th",{key:0,class:e.normalizeClass(["w-9 pr-2",n.compact?"py-1.5":"py-3",n.flushEdges?"pl-0":"pl-2"])},[e.createVNode(l2,{"model-value":S.value,onClick:X[1]||(X[1]=e.withModifiers(()=>{},["stop"])),"onUpdate:modelValue":U},null,8,["model-value"])],2)):e.createCommentVNode("",!0),n.expandable?(e.openBlock(),e.createElementBlock("th",{key:1,class:e.normalizeClass(["w-8 pr-2",n.compact?"py-1.5":"py-3",n.flushEdges&&!n.selectable?"pl-0":"pl-2"])},null,2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,(z,D)=>(e.openBlock(),e.createElementBlock("th",{key:z.field,class:e.normalizeClass([l1(D,n.compact?"py-1.5":"py-3"),"whitespace-nowrap text-zinc-500 dark:text-zinc-300 font-medium",W(z.align),D===0&&!n.expandable&&!n.selectable?"wpic-table__sticky sticky left-0 z-10":""]),style:e.normalizeStyle({...s1(z)})},[e.renderSlot(V.$slots,"th-"+z.field,{col:z,sortField:h.value,sortDir:c.value,toggleSort:E},()=>[z.sortable?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:K=>E(z.field),class:e.normalizeClass(["inline-flex items-center gap-1 cursor-pointer transition-colors whitespace-nowrap",z.align==="right"?"ml-auto":""]),style:{color:"inherit"}},[e.createTextVNode(e.toDisplayString(z.label)+" ",1),h.value===z.field&&c.value==="asc"?(e.openBlock(),e.createBlock(e.unref(g.ChevronUp),{key:0,size:11,style:{color:"#5E6AD2"}})):h.value===z.field&&c.value==="desc"?(e.openBlock(),e.createBlock(e.unref(g.ChevronDown),{key:1,size:11,style:{color:"#5E6AD2"}})):(e.openBlock(),e.createBlock(e.unref(g.ChevronsUpDown),{key:2,size:10,style:{opacity:"0.3"}}))],10,N0)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(z.label),1)],64))])],6))),128))])])):e.createCommentVNode("",!0),n.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("tbody",S0,[n.summaryRow?(e.openBlock(),e.createElementBlock("tr",L0,[n.selectable?(e.openBlock(),e.createElementBlock("td",D0)):e.createCommentVNode("",!0),n.expandable?(e.openBlock(),e.createElementBlock("td",F0)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,(z,D)=>(e.openBlock(),e.createElementBlock("td",{key:z.field,class:e.normalizeClass([l1(D,n.compact?"py-1":"py-2.5"),W(z.align),D===0&&!n.expandable&&!n.selectable?"wpic-table__sticky sticky left-0 z-10 text-zinc-900 dark:text-zinc-100":"text-zinc-700 dark:text-zinc-200"])},[e.renderSlot(V.$slots,"summary-"+z.field,{row:n.summaryRow,value:n.summaryRow[z.field]},()=>[e.createTextVNode(e.toDisplayString(n.summaryRow[z.field]??"—"),1)])],2))),128))])):e.createCommentVNode("",!0),P.value.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(P.value,(z,D)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:D},[e.createElementVNode("tr",{class:e.normalizeClass(["wpic-table__row group wpic-table__divider border-b border-zinc-100 dark:border-zinc-800",[n.expandable&&l.value.has(D)?"border-b-0":"",n.rowClass?.(z)]]),style:e.normalizeStyle({cursor:n.rowClickable||n.expandable?"pointer":"default",...n.rowStyle?.(z)??{}}),onClick:K=>n.expandable?a(D):n.rowClickable&&s("row-click",z)},[n.selectable?(e.openBlock(),e.createElementBlock("td",{key:0,class:e.normalizeClass(["w-9 pr-2",n.compact?"py-1":"py-2.5",n.flushEdges?"pl-0":"pl-2"]),onClick:X[2]||(X[2]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(l2,{"model-value":M.value.has(Z(z,D)),"onUpdate:modelValue":K=>B(z,D,K)},null,8,["model-value","onUpdate:modelValue"])],2)):e.createCommentVNode("",!0),n.expandable?(e.openBlock(),e.createElementBlock("td",{key:1,class:e.normalizeClass(["w-8 pr-1 text-zinc-400 dark:text-zinc-500",n.compact?"py-1":"py-2.5",n.flushEdges&&!n.selectable?"pl-0":"pl-3"])},[l.value.has(D)?(e.openBlock(),e.createBlock(e.unref(g.ChevronDown),{key:0,size:13,style:{transition:"transform .15s"}})):(e.openBlock(),e.createBlock(e.unref(g.ChevronRight),{key:1,size:13,style:{transition:"transform .15s"}}))],2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,(K,e1)=>(e.openBlock(),e.createElementBlock("td",{key:K.field,class:e.normalizeClass([l1(e1,n.compact?"py-1":"py-2.5"),W(K.align),e1===0&&!n.expandable&&!n.selectable?"wpic-table__sticky sticky left-0 z-10 text-zinc-900 dark:text-zinc-100 font-medium":"text-zinc-700 dark:text-zinc-200"]),onClick:r1=>n.expandable?(n.rowClickable&&s("row-click",z),r1.stopPropagation()):void 0},[e.renderSlot(V.$slots,K.field,{row:z,value:z[K.field]},()=>[e.createTextVNode(e.toDisplayString(z[K.field]??"—"),1)])],10,A0))),128))],14,$0),n.expandable&&l.value.has(D)?(e.openBlock(),e.createElementBlock("tr",T0,[e.createElementVNode("td",{colspan:n.columns.length+(n.expandable?1:0)+(n.selectable?1:0),class:"wpic-table__pad-x pb-3 pt-0"},[e.renderSlot(V.$slots,"expand",{row:z})],8,H0)])):e.createCommentVNode("",!0)],64))),128)):(e.openBlock(),e.createElementBlock("tr",P0,[e.createElementVNode("td",{colspan:n.columns.length+(n.expandable?1:0)+(n.selectable?1:0),class:"py-16 text-center text-zinc-400 dark:text-zinc-500"},[e.createElementVNode("div",W0,[e.renderSlot(V.$slots,"empty-icon"),e.createTextVNode(" "+e.toDisplayString(n.emptyText??"No data"),1)])],8,j0)]))]))])]),n.showFooter&&q.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center justify-between wpic-table__divider border-t border-zinc-100 dark:border-zinc-800 wpic-table__pad-x",n.compact?"py-1":"py-2.5"])},[e.createElementVNode("span",R0,[t1.value>1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(O.value)+"–"+e.toDisplayString(i1.value)+" "+e.toDisplayString(n.labels?.of??"of")+" "+e.toDisplayString(q.value),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(q.value)+" "+e.toDisplayString(q.value===1?n.labels?.item??"item":n.labels?.items??"items"),1)],64))]),t1.value>1?(e.openBlock(),e.createElementBlock("div",I0,[e.createElementVNode("button",{"aria-label":n.labels?.previous??"Previous page",onClick:X[3]||(X[3]=z=>F.value--),disabled:F.value===1,class:"h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer disabled:opacity-30 hover:bg-zinc-50 dark:hover:bg-zinc-800/50 text-zinc-400"},[e.createVNode(e.unref(g.ChevronLeft),{size:13})],8,Z0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.value,z=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:z},[z==="…"?(e.openBlock(),e.createElementBlock("span",U0,"…")):(e.openBlock(),e.createElementBlock("button",{key:1,onClick:D=>F.value=z,class:e.normalizeClass(["h-7 min-w-7 px-2 rounded-md text-sm font-medium transition-colors cursor-pointer",F.value===z?"":"text-zinc-700 dark:text-zinc-200 hover:bg-zinc-100 dark:hover:bg-zinc-700"]),style:e.normalizeStyle(F.value===z?"background:rgba(94,106,210,0.1);color:#5E6AD2":void 0)},e.toDisplayString(z),15,K0))],64))),128)),e.createElementVNode("button",{"aria-label":n.labels?.next??"Next page",onClick:X[4]||(X[4]=z=>F.value++),disabled:F.value===t1.value,class:"h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer disabled:opacity-30 hover:bg-zinc-50 dark:hover:bg-zinc-800/50 text-zinc-400"},[e.createVNode(e.unref(g.ChevronRight),{size:13})],8,O0)])):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2))}}),q0={class:"w-spreadsheet-frame__surface"},Q0={key:0,class:"w-spreadsheet-frame__heading"},J0={key:1,class:"w-spreadsheet-frame__status"},X0=["title","aria-label"],G0={key:1,class:"flex min-h-64 items-center justify-center gap-3 text-zinc-400 dark:text-zinc-500"},_0={key:0,class:"w-spreadsheet__row-axis-col"},e3={key:0},n3={key:0,class:"w-spreadsheet__corner"},t3={key:0,class:"w-spreadsheet__axis"},l3=["colspan","title","tabindex","onClick","onKeydown","onPointerenter","onPointerdown"],c3={key:0,class:"w-spreadsheet__editor"},a3=["type","value","min","placeholder","onInput"],o3=["onPointerdown"],r3=e.defineComponent({__name:"WSpreadsheet",props:{columns:{},rows:{},showAxes:{type:Boolean,default:!0},showColumnLetters:{type:Boolean,default:!0},showRowNumbers:{type:Boolean,default:!0},minWidth:{default:"960px"},maxHeight:{default:"68vh"},sortable:{type:Boolean},expandable:{type:Boolean},showExpandButton:{type:Boolean},actionsOnHover:{type:Boolean},downloadable:{type:Boolean},showDownloadButton:{type:Boolean},downloadFilename:{},fillHandle:{type:Boolean},expanded:{type:Boolean},downloadRequest:{},loading:{type:Boolean}},emits:["update:expanded","cell-change"],setup(n,{expose:d,emit:t}){const o=n,s=t,l=e.computed(()=>o.showAxes&&o.showColumnLetters),a=e.computed(()=>o.showAxes&&o.showRowNumbers),m=e.computed(()=>o.columns.some(x=>x.sticky)),f=e.ref(null),h=e.ref("asc"),c=e.ref(o.expanded??!1),E=e.ref(null),w=e.ref(null),L=e.ref(null),b=e.ref(null),C=e.ref(null);function p(){if(!o.downloadable)return;const x=N=>`"${String(N??"").replace(/"/g,'""')}"`,T=M.value.map(N=>o.columns.map(H=>x(P(N,H.key))).join(",")).join(`\r
|
|
2
|
-
`),$=new Blob([`\uFEFF${T}`],{type:"text/csv;charset=utf-8"}),G=URL.createObjectURL($),Q=document.createElement("a");Q.href=G,Q.download=o.downloadFilename||"spreadsheet.csv",Q.click(),URL.revokeObjectURL(G)}function F(x,T=!0){if(c.value===x)return;const $=performance.now();console.debug(`[WSpreadsheet] ${x?"expand":"minimize"} requested`),c.value=x,T&&s("update:expanded",x),requestAnimationFrame(()=>requestAnimationFrame(()=>{console.debug(`[WSpreadsheet] ${x?"expand":"minimize"} painted in ${(performance.now()-$).toFixed(1)}ms`)}))}e.watch(()=>o.expanded,x=>{x!=null&&F(x,!1)}),e.watch(()=>o.downloadRequest,(x,T)=>{x!=null&&x!==T&&p()}),d({expand:()=>{o.expandable&&F(!0)},collapse:()=>{F(!1)},toggleExpanded:()=>{o.expandable&&F(!c.value)},download:p});function q(x){x.key==="Escape"&&c.value&&F(!1)}function t1(x){if(x.target?.closest(".w-spreadsheet__cell")?.querySelector(".w-spreadsheet__input"))return;b.value=null,C.value=null;const G=document.activeElement;G&&E.value?.contains(G)&&G.blur()}e.onMounted(()=>{document.addEventListener("keydown",q),document.addEventListener("pointerdown",t1)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",q),document.removeEventListener("pointerdown",t1),window.removeEventListener("pointerup",D)});function P(x,T){return x.cells.find($=>$.key===T)?.value??""}function Z(x){if(typeof x=="number")return x;const T=String(x).trim().replace(/[\s,]/g,"");return T!==""&&/^-?\d+(\.\d+)?$/.test(T)?Number(T):String(x).toLocaleLowerCase()}const M=e.computed(()=>{if(!f.value)return o.rows;const x=o.rows.filter(G=>G.sortable!==!1),T=h.value==="asc"?1:-1;x.sort((G,Q)=>{const N=Z(P(G,f.value)),H=Z(P(Q,f.value));return typeof N=="number"&&typeof H=="number"?(N-H)*T:String(N).localeCompare(String(H),void 0,{numeric:!0})*T});let $=0;return o.rows.map(G=>G.sortable===!1?G:x[$++])});function A(x){const T=o.columns.find($=>$.key===x.key);return!!(o.sortable&&x.variant==="header"&&T?.sortable!==!1)}function S(x){A(x)&&(f.value===x.key?h.value=h.value==="asc"?"desc":"asc":(f.value=x.key,h.value="asc"))}function B(x,T){return x.cells.slice(0,T).reduce(($,G)=>$+(G.colspan||1),0)}function U(x,T){return!!o.columns[B(x,T)]?.sticky}function O(x,T){const $=B(x,T);return!!(o.columns[$]?.sticky&&!o.columns.slice(0,$).some(G=>G.sticky))}function i1(x,T){const $=B(x,T);if(!o.columns[$]?.sticky)return;const G=o.columns.slice(0,$).map(Q=>Q.width||"0px");return{left:G.length?`calc(${G.join(" + ")})`:"0px"}}function j(x,T){return`${x.key}\0${T.key}`}function J(x,T){!T.editable||w.value||(b.value={rowKey:x.key,cellKey:T.key},C.value=null)}function W(x,T){return b.value?.rowKey===x.key&&b.value?.cellKey===T.key}function l1(x,T,$){const G=M.value[x];!o.fillHandle||!$.editable||!G||!W(G,$)||(C.value=null,w.value={row:x,cell:T,value:String($.value??"")},L.value={row:x,cell:T},window.addEventListener("pointerup",D,{once:!0}))}function s1(x,T){w.value&&(L.value={row:x,cell:T})}function V(x,T){if(!w.value||!L.value)return!1;const $=Math.min(w.value.row,L.value.row),G=Math.max(w.value.row,L.value.row),Q=Math.min(w.value.cell,L.value.cell),N=Math.max(w.value.cell,L.value.cell);return x>=$&&x<=G&&T>=Q&&T<=N}function X(x,T){if(!V(x,T)||!w.value||!L.value)return{};const $=Math.min(w.value.row,L.value.row),G=Math.max(w.value.row,L.value.row),Q=Math.min(w.value.cell,L.value.cell),N=Math.max(w.value.cell,L.value.cell);return{"w-spreadsheet__cell--fill-range":!0,"w-spreadsheet__cell--fill-top":x===$,"w-spreadsheet__cell--fill-bottom":x===G,"w-spreadsheet__cell--fill-left":T===Q,"w-spreadsheet__cell--fill-right":T===N}}function z(x,T){const $=j(x,T);return{"w-spreadsheet__cell--fill-completed":!!C.value?.cells.has($),"w-spreadsheet__cell--fill-source":C.value?.source===$}}function D(){if(!w.value||!L.value)return;const x=w.value,T=L.value,$=Math.min(x.row,T.row),G=Math.max(x.row,T.row),Q=Math.min(x.cell,T.cell),N=Math.max(x.cell,T.cell),H=new Set,R=M.value[x.row],c1=R?.cells[x.cell];for(let p1=$;p1<=G;p1++){const x1=M.value[p1];if(x1)for(let M1=Q;M1<=N;M1++){const w1=x1.cells[M1];w1?.editable&&(H.add(j(x1,w1)),s("cell-change",{rowKey:x1.key,cellKey:w1.key,value:x.value,row:x1,cell:w1}))}}w.value=null,L.value=null,C.value=R&&c1?{cells:H,source:j(R,c1)}:null}function K(x){let T=x+1,$="";for(;T>0;)T-=1,$=String.fromCharCode(65+T%26)+$,T=Math.floor(T/26);return $}function e1(x){return[`w-spreadsheet__cell--${x.variant||"default"}`,`w-spreadsheet__cell--${x.align||"left"}`,`w-spreadsheet__cell--tone-${x.tone||"default"}`,{"w-spreadsheet__cell--wrap":!!x.wrap},x.class||""]}function r1(x,T,$){const G=$.target.value;s("cell-change",{rowKey:x.key,cellKey:T.key,value:G,row:x,cell:T})}function h1(x){const $=x.currentTarget.previousElementSibling;$?.focus(),$?.showPicker?.()}return(x,T)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"frameRef",ref:E,class:e.normalizeClass(["w-spreadsheet-frame",{"w-spreadsheet-frame--expanded":c.value}])},[c.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"w-spreadsheet-frame__backdrop","aria-label":"Restore spreadsheet",onClick:T[0]||(T[0]=$=>F(!1))})):e.createCommentVNode("",!0),e.createElementVNode("div",q0,[n.expandable&&(n.showExpandButton!==!1||c.value)||n.downloadable&&(n.showDownloadButton!==!1||c.value)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["w-spreadsheet-frame__toolbar",{"w-spreadsheet-frame__toolbar--hover":n.actionsOnHover&&!c.value}])},[c.value&&x.$slots["expanded-header"]?(e.openBlock(),e.createElementBlock("div",Q0,[e.renderSlot(x.$slots,"expanded-header")])):e.createCommentVNode("",!0),x.$slots["toolbar-status"]?(e.openBlock(),e.createElementBlock("div",J0,[e.renderSlot(x.$slots,"toolbar-status")])):e.createCommentVNode("",!0),e.renderSlot(x.$slots,"toolbar"),n.downloadable&&(n.showDownloadButton!==!1||c.value)?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"w-spreadsheet-frame__expand",title:"Download spreadsheet","aria-label":"Download spreadsheet",onClick:p},[e.createVNode(e.unref(g.Download),{size:16})])):e.createCommentVNode("",!0),n.expandable&&(n.showExpandButton!==!1||c.value)?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"w-spreadsheet-frame__expand",title:c.value?"Restore spreadsheet":"Expand spreadsheet","aria-label":c.value?"Restore spreadsheet":"Expand spreadsheet",onClick:T[1]||(T[1]=$=>F(!c.value))},[c.value?(e.openBlock(),e.createBlock(e.unref(g.Minimize),{key:0,size:16})):(e.openBlock(),e.createBlock(e.unref(g.Expand),{key:1,size:16}))],8,X0)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0),n.loading?(e.openBlock(),e.createElementBlock("div",G0,[e.createVNode(O1),T[2]||(T[2]=e.createElementVNode("span",null,"Preparing sales estimate…",-1))])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["w-spreadsheet",{"w-spreadsheet--with-column-axis":l.value}]),style:e.normalizeStyle({maxHeight:c.value?"calc(100vh - 96px)":n.maxHeight})},[e.createElementVNode("table",{class:e.normalizeClass(["w-spreadsheet__table",{"w-spreadsheet__table--sticky-columns":m.value}]),style:e.normalizeStyle({minWidth:n.minWidth})},[e.createElementVNode("colgroup",null,[a.value?(e.openBlock(),e.createElementBlock("col",_0)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,$=>(e.openBlock(),e.createElementBlock("col",{key:$.key,style:e.normalizeStyle({width:$.width})},null,4))),128))]),l.value?(e.openBlock(),e.createElementBlock("thead",e3,[e.createElementVNode("tr",null,[a.value?(e.openBlock(),e.createElementBlock("th",n3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,($,G)=>(e.openBlock(),e.createElementBlock("th",{key:$.key,class:"w-spreadsheet__axis"},e.toDisplayString($.label||K(G)),1))),128))])])):e.createCommentVNode("",!0),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,($,G)=>(e.openBlock(),e.createElementBlock("tr",{key:$.key,class:e.normalizeClass({"w-spreadsheet__row--sticky":$.sticky})},[a.value?(e.openBlock(),e.createElementBlock("th",t3,e.toDisplayString(G+1),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.cells,(Q,N)=>(e.openBlock(),e.createElementBlock("td",{key:Q.key,class:e.normalizeClass(["w-spreadsheet__cell",[e1(Q),{"w-spreadsheet__cell--sortable":A(Q),"w-spreadsheet__cell--sticky":U($,N),"w-spreadsheet__cell--sticky-first":O($,N),"w-spreadsheet__cell--active":W($,Q)},X(G,N),z($,Q)]]),colspan:Q.colspan||1,title:Q.title,style:e.normalizeStyle(i1($,N)),tabindex:A(Q)?0:void 0,onClick:H=>S(Q),onKeydown:[e.withKeys(e.withModifiers(H=>S(Q),["prevent"]),["enter"]),e.withKeys(e.withModifiers(H=>S(Q),["prevent"]),["space"])],onPointerenter:H=>s1(G,N),onPointerdown:H=>J($,Q)},[e.renderSlot(x.$slots,`cell-${Q.key}`,{row:$,cell:Q,rowIndex:G},()=>[Q.editable?(e.openBlock(),e.createElementBlock("div",c3,[e.createElementVNode("input",{class:e.normalizeClass(["w-spreadsheet__input",{"w-spreadsheet__input--date":Q.inputType==="date"}]),type:Q.inputType||"text",value:Q.value??"",min:Q.min,placeholder:Q.placeholder,onInput:H=>r1($,Q,H)},null,42,a3),Q.inputType==="date"?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"w-spreadsheet__calendar","aria-label":"Choose date",title:"Choose date",onClick:h1},[e.createVNode(e.unref(g.CalendarDays),{size:16})])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(Q.value??""),1)],64))]),A(Q)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.value===Q.key?h.value==="asc"?e.unref(g.ChevronUp):e.unref(g.ChevronDown):e.unref(g.ChevronsUpDown)),{key:0,class:"w-spreadsheet__sort-icon",size:14})):e.createCommentVNode("",!0),n.fillHandle&&Q.editable&&W($,Q)?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"w-spreadsheet__fill-handle","aria-label":"Fill adjacent cells",title:"Drag to fill adjacent cells",onPointerdown:e.withModifiers(H=>l1(G,N,Q),["stop","prevent"])},null,40,o3)):e.createCommentVNode("",!0)],46,l3))),128))],2))),128))])],6)],6))])],2))}}),b1=(n,d)=>{const t=n.__vccOpts||n;for(const[o,s]of d)t[o]=s;return t},i3={},s3={class:"min-w-40 rounded-lg bg-white p-1.5 shadow-md shadow-zinc-900/5 dark:bg-zinc-700 dark:shadow-black/20"};function d3(n,d){return e.openBlock(),e.createElementBlock("div",s3,[e.renderSlot(n.$slots,"default")])}const c2=b1(i3,[["render",d3]]),u3=["disabled"],L1=e.defineComponent({__name:"WActionMenuItem",props:{danger:{type:Boolean},disabled:{type:Boolean}},emits:["click"],setup(n,{emit:d}){const t=d;return(o,s)=>(e.openBlock(),e.createElementBlock("button",{type:"button",disabled:n.disabled,onClick:s[0]||(s[0]=l=>t("click",l)),class:e.normalizeClass(["flex h-8 w-full items-center gap-2 rounded-md px-2 text-left font-medium transition disabled:cursor-not-allowed disabled:opacity-40",n.danger?"text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30":"text-zinc-600 hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-100 dark:hover:bg-zinc-600 dark:hover:text-white"])},[e.renderSlot(o.$slots,"default")],10,u3))}}),w2={light:{trendPositive:"#15803D",trendNegative:"#DB2777",canvas:"#F8F8F8",surface:"#FFFFFF",input:"#FFFFFF",raised:"#F2F3EF",popover:"#FFFFFF",border:"rgb(32 33 29 / 0.07)",borderHover:"rgb(32 33 29 / 0.16)",text:"#20211D",muted:"#64675C",dim:"#707467",accent:"#85C531",onAccent:"#17210B",primary:"#171717",primaryHover:"#303030",onPrimary:"#FFFFFF",secondary:"#EFEFEF",secondaryHover:"#E3E3E3",onSecondary:"#20211D",secondaryShadow:"none",switchOn:"linear-gradient(35deg, #32dc08 0%, #9de400 48%, #e9e600 100%)",switchOff:"#D4D4D8",switchDisabled:"#E4E4E7",switchThumb:"#FFFFFF",focusRing:"color-mix(in srgb, var(--wpic-accent) 18%, transparent)",positive:"#85C531",negative:"#B94238"},dark:{trendPositive:"#86EFAC",trendNegative:"#FDA4AF",canvas:"#090A05",surface:"#151515",input:"#151515",raised:"#2A2A28",popover:"#1F201D",border:"rgb(255 255 255 / 0.06)",borderHover:"rgb(255 255 255 / 0.14)",text:"#F5F5F5",muted:"#B4B4B4",dim:"#969696",accent:"#85C531",onAccent:"#17210B",primary:"#FFFFFF",primaryHover:"#E8E8E8",onPrimary:"#171717",secondary:"linear-gradient(180deg, #3A3B36, #30312D)",secondaryHover:"linear-gradient(180deg, #40413B, #353630)",onSecondary:"#F5F5F5",secondaryShadow:"inset 0 1px 0 rgb(255 255 255 / 0.15), 0 1px 2px rgb(0 0 0 / 0.12)",switchOn:"linear-gradient(35deg, #32dc08 0%, #9de400 48%, #e9e600 100%)",switchOff:"#343530",switchDisabled:"#252525",switchThumb:"#FFFFFF",focusRing:"color-mix(in srgb, var(--wpic-accent) 18%, transparent)",positive:"#85C531",negative:"#F0A09A"}},m3={light:["#3B73E1","#0891A6","#8B5CD6","#C58A16","#D64D79","#527FA8"],dark:["#7C9FE0","#5FB8C4","#AF94D5","#D8B26A","#D88FA5","#94A8BD"]};function B2(n,d={}){const t={...w2[n],...d},o={};for(const[s,l]of Object.entries(t))o[`--wpic-${s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`)}`]=l;return Object.assign(o,{"--bg-main":t.canvas,"--bg-card":t.surface,"--bg-input":t.input,"--border-subtle":t.border,"--border-strong":t.border,"--border-hover":t.borderHover,"--text-main":t.text,"--text-muted":t.muted,"--text-dim":t.dim,"--wpic-primary":t.accent,"--wpic-primary-hover":t.accent,"--wpic-control-height":"36px","--wpic-table-border":n==="light"?`color-mix(in srgb, ${t.text} 11.5%, ${t.surface})`:t.border,"--wpic-segment-active":n==="dark"?t.secondaryHover:t.surface,"--wpic-segment-shadow":n==="dark"?t.secondaryShadow:`inset 0 0 0 1px ${t.border}, 0 1px 2px rgb(0 0 0 / 0.08)`,"--wpic-button-primary":t.primary,"--wpic-button-primary-hover":t.primaryHover}),o}const M2=Symbol("wpic-theme");function T1(){return e.inject(M2,e.computed(()=>null))}const h3=["data-wpic-theme"],y1=e.defineComponent({__name:"WPopover",props:{open:{type:Boolean},anchor:{},placement:{},width:{},minWidth:{},height:{},minHeight:{},maxHeight:{},panelScroll:{type:Boolean,default:!0},offset:{},matchAnchorWidth:{type:Boolean},freezePositionOnOpen:{type:Boolean,default:!0},flip:{type:Boolean,default:!0},autoPlacement:{type:Boolean},zIndex:{default:9999},extraPanels:{}},emits:["close"],setup(n,{emit:d}){const t=n,o=T1(),s=d,l=Symbol.for("wpic-ui-popover-descendants"),a=e.inject(l,null),m=new Set;e.provide(l,{add(B){m.add(B),a?.add(B)},remove(B){m.delete(B),a?.remove(B)}});const f=e.computed(()=>{const B=t.anchor;return B?e.isRef(B)?B.value:B:null}),h=e.ref(null),c=e.ref(null),E=e.computed(()=>c.value??t.placement??"bottom-start"),w=e.computed(()=>{const B=[n1.offset(t.offset??6)];return c.value||(t.autoPlacement?B.push(n1.autoPlacement({alignment:"start"})):t.flip&&B.push(n1.flip())),B.push(n1.shift({padding:t.autoPlacement?8:4,crossAxis:t.autoPlacement})),B.push(n1.size({padding:8,apply({availableHeight:U,rects:O,elements:i1}){const j=Math.max(U-8,50),W={maxHeight:t.maxHeight?`min(${t.maxHeight}, ${j}px)`:`${j}px`,overflowY:t.panelScroll?"auto":"hidden"};if(t.height&&(W.height=`min(${t.height}, ${j}px)`),t.minHeight&&(W.minHeight=`min(${t.minHeight}, ${j}px)`),t.matchAnchorWidth){const l1=`${O.reference.width}px`;W.width=l1,W.minWidth=l1}Object.assign(i1.floating.style,W)}})),B}),{floatingStyles:L,placement:b,update:C,isPositioned:p}=n1.useFloating(f,h,{placement:E,strategy:"fixed",open:e.computed(()=>t.open),whileElementsMounted:n1.autoUpdate,middleware:w}),F=e.computed(()=>{const B=b.value;return B.startsWith("top")?"bottom":B.startsWith("bottom")?"top":B.startsWith("left")?"right":B.startsWith("right")?"left":"top"}),q=B=>{const U=B.target,O=f.value,i1=h.value;i1&&i1.contains(U)||[...m].some(j=>j.contains(U))||O&&O.contains(U)||t.extraPanels?.some(j=>j?.contains(U))||s("close")},t1=B=>{if(B.key!=="Escape"||!t.open||[...m].some(O=>O.isConnected&&O.style.display!=="none"))return;B.preventDefault(),B.stopImmediatePropagation(),s("close");const U=f.value;U?.matches("button, input, [tabindex]")?U.focus():U?.querySelector("button, input, [tabindex]")?.focus()};let P=!1,Z=!1;function M(){Z||(document.addEventListener("pointerdown",q,!0),document.addEventListener("keydown",t1,!0),Z=!0)}function A(){Z&&(document.removeEventListener("pointerdown",q,!0),document.removeEventListener("keydown",t1,!0),Z=!1)}e.watch(()=>t.open,B=>{B?e.nextTick(()=>{P||!t.open||(t.autoPlacement&&h.value&&(h.value.style.maxHeight=""),C(),M())}):(c.value=null,A())},{immediate:!0}),e.watch(h,(B,U)=>{U&&a?.remove(U),B&&a?.add(B)}),e.watch(p,B=>{B&&t.open&&t.freezePositionOnOpen&&!c.value&&(c.value=b.value)}),e.onBeforeUnmount(()=>{P=!0,A(),h.value&&a?.remove(h.value)});const S=e.computed(()=>({...t.matchAnchorWidth?{}:{width:t.width??"auto"},...t.minWidth?{minWidth:t.minWidth}:{},transformOrigin:F.value,zIndex:t.zIndex}));return(B,U)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",class:"wpic-popover"},[e.withDirectives(e.createElementVNode("div",{ref_key:"floatingEl",ref:h,"data-wpic-theme":e.unref(o)?.mode,class:e.normalizeClass([{"wpic-theme":e.unref(o),dark:e.unref(o)?.mode==="dark"},"wpic-popover-panel flex flex-col bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl shadow-xl dark:shadow-black/40 overflow-hidden"]),style:e.normalizeStyle([e.unref(o)?.variables,e.unref(L),S.value])},[e.renderSlot(B.$slots,"default")],14,h3),[[e.vShow,n.open]])]))}}),p3={key:0,class:"fixed right-0 top-0 z-[9997] flex h-full w-20 items-center justify-center border-l-2 border-[var(--wpic-primary)] bg-[var(--wpic-primary)]/10 text-[var(--wpic-primary)] pointer-events-none"},v3=["data-variant","data-maximized"],f3=["title"],g3={class:"min-w-0 flex-1 px-2 text-center"},C3={class:"truncate font-medium text-zinc-700 dark:text-zinc-200"},k3={key:0,class:"truncate text-zinc-500 dark:text-zinc-400"},z3={class:"flex shrink-0 items-center gap-1"},b3=["title"],y3=["title"],x3=["title"],w3=["title"],B3={class:"flex h-11 shrink-0 items-center justify-between px-3"},M3={class:"font-medium text-zinc-700 dark:text-zinc-200"},V3=["title"],E3={class:"space-y-2 px-3 pb-3"},N3={class:"truncate"},S3={class:"flex-1 overflow-y-auto overflow-x-visible px-2 pb-3"},L3={class:"mb-2 flex h-7 items-center justify-between px-2 font-medium text-zinc-500 dark:text-zinc-400"},D3={class:"truncate"},F3=["title"],$3={class:"space-y-0.5"},A3={key:0,class:"rounded-lg border border-dashed border-zinc-200 px-2 py-2 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400"},T3=["onMouseenter"],H3=["onClick"],P3={class:"min-w-0 flex-1 truncate"},j3={key:0,class:"shrink-0 text-zinc-400"},W3={key:0,class:"px-3 py-2 text-zinc-400 dark:text-zinc-500"},R3=["onPointerdown","onClick"],I3={class:"min-w-0 flex-1 truncate"},Z3={class:"shrink-0 text-zinc-400"},U3={class:"mt-4"},K3={class:"flex h-7 items-center px-2 font-medium text-zinc-500 dark:text-zinc-400"},O3={class:"truncate"},Y3={class:"space-y-0.5"},q3={key:0,class:"rounded-lg border border-dashed border-zinc-200 px-2 py-2 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400"},Q3=["onPointerdown","onClick"],J3={class:"block truncate"},X3={class:"shrink-0 text-zinc-400"},G3=["onClick"],_3=["onPointerenter","onMouseenter"],e4={class:"truncate"},n4={class:"flex min-h-0 flex-1"},t4={class:"flex min-w-0 flex-1 flex-col"},l4={key:0,class:"flex h-full flex-col items-center justify-center px-5 text-center text-zinc-500 dark:text-zinc-400"},c4={class:"font-medium"},a4={key:1,class:"flex h-full flex-col items-center justify-center px-5 text-center"},o4={class:"mb-3 flex h-11 w-11 items-center justify-center rounded-xl bg-zinc-100 text-zinc-500 dark:bg-zinc-700 dark:text-zinc-300"},r4={class:"font-semibold text-zinc-800 dark:text-zinc-100"},i4={key:0,class:"mt-1 max-w-xs text-zinc-500 dark:text-zinc-400"},s4={key:2,class:"space-y-4"},d4={class:"max-w-[82%]"},u4=["src","alt"],m4={class:"max-w-40 truncate"},h4={key:0,class:"shrink-0 text-zinc-400"},p4={key:0,class:"flex items-center gap-2 text-zinc-500 dark:text-zinc-400"},v4={key:1,class:"wpic-chat-loading-card",role:"status","aria-label":"Generating image"},f4=["innerHTML","onClick"],g4=["href","onClick"],C4=["src"],k4=["title","aria-label","onClick"],z4=["title","aria-label","onClick"],b4=["title","onClick"],y4=["onClick"],x4=["title","onClick"],w4={key:0,class:"mb-2 flex flex-wrap justify-end gap-1.5"},B4=["src","alt"],M4={class:"max-w-40 truncate"},V4={key:0,class:"shrink-0 text-zinc-400"},E4={key:1,class:"shrink-0 text-zinc-400"},N4=["title","onClick"],S4={class:"wpic-chat-panel__composer rounded-xl border border-zinc-200 bg-zinc-50 transition-colors focus-within:border-[var(--wpic-primary)]/50 dark:border-zinc-700 dark:bg-zinc-700"},L4={key:0,class:"mx-2 mt-2 overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-600"},D4=["onMousedown"],F4={class:"min-w-0 truncate font-medium text-zinc-900 dark:text-zinc-100"},$4={key:0,class:"max-w-32 shrink-0 truncate text-xs text-zinc-500 dark:text-zinc-400"},A4=["accept"],T4=["value","placeholder","disabled"],H4={class:"flex items-center justify-between px-2 pb-2"},P4=["disabled","title"],j4=["title"],W4=["disabled","title"],z2=80,R4=e.defineComponent({__name:"WChatPanel",props:{open:{type:Boolean},messages:{},mentionItems:{default:()=>[]},projects:{default:()=>[]},sessions:{default:()=>[]},modelValue:{default:""},title:{default:"Chat"},subtitle:{default:""},selectedProjectId:{default:null},selectedSessionId:{default:null},placeholder:{default:"Ask anything..."},emptyTitle:{default:"How can I help?"},emptyDescription:{default:""},noProjectsLabel:{default:"No projects yet"},noConversationsLabel:{default:"No conversations yet"},allLabel:{default:"All"},recentLabel:{default:"Recent"},projectsLabel:{default:"Projects"},conversationsLabel:{default:"Conversations"},sendLabel:{default:"Send"},newLabel:{default:"New chat"},newProjectLabel:{default:"New project"},newConversationLabel:{default:"New conversation"},renameProjectLabel:{default:"Rename project"},renameConversationLabel:{default:"Rename conversation"},deleteProjectLabel:{default:"Delete project"},deleteConversationLabel:{default:"Delete conversation"},clearLabel:{default:"Clear"},copyLabel:{default:"Copy"},copiedLabel:{default:"Copied"},newChatFromMessageLabel:{default:"Start new chat from this message"},attachFilesLabel:{default:"Attach files"},removeAttachmentLabel:{default:"Remove attachment"},stopLabel:{default:"Stop"},applyPromptLabel:{default:"Apply prompt"},applyAllLabel:{default:"Apply all"},applySettingLabel:{default:"Apply setting"},thinkingLabel:{default:"Thinking..."},dockLabel:{default:"Dock"},undockLabel:{default:"Undock"},closeLabel:{default:"Close"},helpfulLabel:{default:"Helpful"},notHelpfulLabel:{default:"Not helpful"},attachments:{default:()=>[]},accept:{default:""},customAttachmentPicker:{type:Boolean,default:!1},showNavigator:{type:Boolean,default:!0},hideNewConversation:{type:Boolean,default:!1},hideClear:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},cancellable:{type:Boolean,default:!1},docked:{type:Boolean,default:!1},maximized:{type:Boolean,default:!1},maximizedMargin:{default:20},width:{default:420},height:{default:560},x:{default:-1},y:{default:-1},topOffset:{default:0},minWidth:{default:340},minHeight:{default:400},zIndex:{default:80},variant:{default:"default"}},emits:["close","send","clear","new","new-project","new-conversation","select-project","select-session","rename-project","rename-session","delete-project","delete-session","move-session","edit-message","new-chat-from-message","message-feedback","apply-message-proposal","navigate","cancel","attach","files-selected","remove-attachment","update:modelValue","update:docked","update:maximized","update:width","update:height","update:x","update:y"],setup(n,{emit:d}){const t=n,o=d,s=e.useSlots(),l=e.ref(null),a=e.ref(null),m=e.ref(null),f=e.ref(null),h=e.ref(null),c=e.ref(null),E=e.ref(0),w=e.ref(0),L=e.ref(!1),b=e.ref(null),C=e.ref(null);let p=null;const F=e.ref(!1),q=e.ref(!1),t1=e.ref(!1);e.ref(new Set);const P=e.ref(null),Z=e.ref(null),M=e.ref({}),A=e.ref(null);let S=null,B=null;function U(){B?.disconnect(),B=null;const r=a.value,i=h.value;if(!r||!i||typeof ResizeObserver>"u")return;const u=()=>i.style.setProperty("--wpic-chat-footer-height",`${r.getBoundingClientRect().height}px`);u(),B=new ResizeObserver(u),B.observe(r)}const O=e.computed(()=>A.value?[]:t.messages.filter(r=>r.role!=="system")),i1=e.computed(()=>t.loading||A.value!==null),j=e.computed(()=>t.modelValue.trim().length>0&&!t.loading),J=e.computed(()=>t.attachments.length>0),W=e.computed(()=>{const r=t.modelValue.slice(0,w.value),i=r.match(/(?:^|\s)@([^\s@]*)$/);return i?{start:r.length-i[0].length+(i[0].startsWith(" ")?1:0),query:i[1].toLowerCase()}:null}),l1=e.computed(()=>{const r=W.value;if(!r)return[];const i=r.query;return t.mentionItems.filter(u=>u.label.toLowerCase().includes(i)).slice(0,6)}),s1=e.computed(()=>t.showNavigator&&L.value),V=e.computed(()=>t.selectedProjectId??null),X=e.computed(()=>t.sessions.filter(r=>!r.projectId)),z=e.computed(()=>{const r=new Map;for(const i of t.projects)r.set(i.id,[]);for(const i of t.sessions){if(!i.projectId)continue;const u=r.get(i.projectId);u&&u.push(i)}return r});function D(r){const i=r.toLowerCase();if(i.includes("doubao-seedance-1-5-pro-251215")||i.includes("doubao seedance 1.5")||i.includes("seedance 1.5")||i.includes("seedance video"))return"jimeng:doubao-seedance-1-5-pro-251215";if(i.includes("imagen 4")||i.includes("imagen-4"))return"google:imagen-4.0-generate-001";if(i.includes("gpt-image-1")||i.includes("gpt image 1"))return"openai:gpt-image-1";if(i.includes("gpt-image-2")||i.includes("gpt image 2"))return"openai:gpt-image-2";if(i.includes("doubao-seedream-4-5-251128"))return"jimeng:doubao-seedream-4-5-251128";if(i.includes("doubao-seedream-4-0-250828"))return"jimeng:doubao-seedream-4-0-250828";if(i.includes("doubao seedream 5")||i.includes("seedream 5")||i.includes("doubao seedream 4.5")||i.includes("seedream 4.5"))return"jimeng:doubao-seedream-4-5-251128";if(i.includes("doubao seedream 4")||i.includes("seedream 4"))return"jimeng:doubao-seedream-4-0-250828";if(i.includes("auto"))return"auto";const u=r.match(/\b([a-z][a-z0-9_-]+):([a-z0-9._-]+)\b/i);if(u)return`${u[1].toLowerCase()}:${u[2]}`}function K(r){if(r!=="auto"){if(r.includes("seedance"))return"video";if(r.includes("gpt-image")||r.includes("imagen")||r.includes("seedream")||r.includes("jimeng:"))return"image"}}function e1(r){const i=[],u=new Set,k=/\b(gpt[-\s]?image[-\s]?[12]|imagen\s*4|doubao\s+seedance\s+1\.5(?:\s+pro)?|seedance\s+1\.5(?:\s+pro)?|doubao\s+seedream\s+(?:5(?:\.0)?|4\.5|4)|seedream\s+(?:5(?:\.0)?|4\.5|4)|[a-z][a-z0-9_-]+:[a-z0-9._-]+|auto)\b/gi;for(const v of r.matchAll(k)){const y=v[1],I=D(y);!I||u.has(I)||(u.add(I),i.push({label:y,value:I}))}return i}function r1(r,i){return r.match(new RegExp(`${i}=["']([^"']+)["']`,"i"))?.[1]}function h1(r){const i={};for(const k of r.matchAll(/\[SETTING\s+([^\]]+)\]([\s\S]*?)\[\/SETTING\]/gi)){const v=k[1]??"",y=r1(v,"key"),I=r1(v,"value")??k[2]?.trim();if(!(!y||!I))if(y==="duration"||y==="fps"||y==="count"){const Y=Number(I);Number.isFinite(Y)&&(i[y]=Y)}else if(y==="model"){const Y=D(I)??D(k[2]?.trim()??"");Y&&(i.model=Y)}else(y==="aspect"||y==="resolution"||y==="format")&&(i[y]=I)}const u=r.split(/\r?\n/).map(k=>k.replace(/^[\s>*-]+/,"").trim()).filter(Boolean);for(const k of u){const v=k.toLowerCase();if(/(supporte|supports?|disponible|available|dur[eé]es?\s*:|ratios?\s*:|jusqu['’]?à|up to)/i.test(v))continue;const y=k.split(":").slice(1).join(":").trim()||k,I=y.match(/\b(\d{1,2}:\d{1,2})\b/);(v.includes("format")||v.includes("aspect")||v.includes("ratio"))&&I&&(i.aspect=I[1]);const Y=y.match(/\b([1248]K)\b/i);(v.includes("résolution")||v.includes("resolution"))&&Y&&(i.resolution=Y[1].toUpperCase());const _=y.match(/\b(\d{1,3})\s*(?:s|sec|secondes?|seconds?)\b/i);(v.includes("durée")||v.includes("duration"))&&_&&(i.duration=Number(_[1]));const a1=y.match(/\b(\d{1,3})\s*fps\b/i);v.includes("fps")&&a1&&(i.fps=Number(a1[1]));const o1=y.match(/\b(\d{1,2})\b/);if((v.includes("count")||v.includes("nombre")||v.includes("variantes"))&&o1&&(i.count=Number(o1[1])),v.includes("modèle")||v.includes("modele")||v.includes("model")){const v1=D(y);v1&&(i.model=v1)}v.includes("jpg")||v.includes("jpeg")?i.format="jpg":v.includes("png")?i.format="png":v.includes("webp")&&(i.format="webp")}return Object.keys(i).length?i:void 0}function x(r){const i=r.match(/\[TASK(?:\s+([^\]]+))?\](?:([\s\S]*?)\[\/TASK\])?/i);if(i){const k=(r1(i[1]??"","value")??i[2]?.trim())?.toLowerCase();if(["image","video","audio","text"].includes(String(k)))return k}const u=r.split(/\r?\n/).map(k=>k.replace(/^[\s>*-]+/,"").trim()).filter(Boolean);for(const k of u){const v=k.toLowerCase(),y=k.split(":").slice(1).join(":").trim().toLowerCase()||v;if(/(task|type|mode|surface|format|réglage|reglage|setting)/i.test(v)){if(/\baudio\b|subtitles?|sous-titres?|transcri|tts|voice|voix/.test(y))return"audio";if(/\bvid[eé]o\b|\bvideo\b|\bfps\b|duration|dur[eé]e/.test(y))return"video";if(/\bimage\b|photo|visuel|illustration|aspect|ratio|resolution|résolution/.test(y))return"image";if(/\btext\b|texte|copy|caption|script/.test(y))return"text"}}}function T(r){const i=r.match(/\[PROMPT\]([\s\S]*?)\[\/PROMPT\]/i)?.[1];if(i){const _=M1(i).trim().replace(/^["“]|["”]$/g,"");if(_)return _}const u=r.replace(/\r\n/g,`
|
|
2
|
+
`),$=new Blob([`\uFEFF${T}`],{type:"text/csv;charset=utf-8"}),G=URL.createObjectURL($),Q=document.createElement("a");Q.href=G,Q.download=o.downloadFilename||"spreadsheet.csv",Q.click(),URL.revokeObjectURL(G)}function F(x,T=!0){if(c.value===x)return;const $=performance.now();console.debug(`[WSpreadsheet] ${x?"expand":"minimize"} requested`),c.value=x,T&&s("update:expanded",x),requestAnimationFrame(()=>requestAnimationFrame(()=>{console.debug(`[WSpreadsheet] ${x?"expand":"minimize"} painted in ${(performance.now()-$).toFixed(1)}ms`)}))}e.watch(()=>o.expanded,x=>{x!=null&&F(x,!1)}),e.watch(()=>o.downloadRequest,(x,T)=>{x!=null&&x!==T&&p()}),d({expand:()=>{o.expandable&&F(!0)},collapse:()=>{F(!1)},toggleExpanded:()=>{o.expandable&&F(!c.value)},download:p});function q(x){x.key==="Escape"&&c.value&&F(!1)}function t1(x){if(x.target?.closest(".w-spreadsheet__cell")?.querySelector(".w-spreadsheet__input"))return;b.value=null,C.value=null;const G=document.activeElement;G&&E.value?.contains(G)&&G.blur()}e.onMounted(()=>{document.addEventListener("keydown",q),document.addEventListener("pointerdown",t1)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",q),document.removeEventListener("pointerdown",t1),window.removeEventListener("pointerup",D)});function P(x,T){return x.cells.find($=>$.key===T)?.value??""}function Z(x){if(typeof x=="number")return x;const T=String(x).trim().replace(/[\s,]/g,"");return T!==""&&/^-?\d+(\.\d+)?$/.test(T)?Number(T):String(x).toLocaleLowerCase()}const M=e.computed(()=>{if(!f.value)return o.rows;const x=o.rows.filter(G=>G.sortable!==!1),T=h.value==="asc"?1:-1;x.sort((G,Q)=>{const N=Z(P(G,f.value)),H=Z(P(Q,f.value));return typeof N=="number"&&typeof H=="number"?(N-H)*T:String(N).localeCompare(String(H),void 0,{numeric:!0})*T});let $=0;return o.rows.map(G=>G.sortable===!1?G:x[$++])});function A(x){const T=o.columns.find($=>$.key===x.key);return!!(o.sortable&&x.variant==="header"&&T?.sortable!==!1)}function S(x){A(x)&&(f.value===x.key?h.value=h.value==="asc"?"desc":"asc":(f.value=x.key,h.value="asc"))}function B(x,T){return x.cells.slice(0,T).reduce(($,G)=>$+(G.colspan||1),0)}function U(x,T){return!!o.columns[B(x,T)]?.sticky}function O(x,T){const $=B(x,T);return!!(o.columns[$]?.sticky&&!o.columns.slice(0,$).some(G=>G.sticky))}function i1(x,T){const $=B(x,T);if(!o.columns[$]?.sticky)return;const G=o.columns.slice(0,$).map(Q=>Q.width||"0px");return{left:G.length?`calc(${G.join(" + ")})`:"0px"}}function j(x,T){return`${x.key}\0${T.key}`}function J(x,T){!T.editable||w.value||(b.value={rowKey:x.key,cellKey:T.key},C.value=null)}function W(x,T){return b.value?.rowKey===x.key&&b.value?.cellKey===T.key}function l1(x,T,$){const G=M.value[x];!o.fillHandle||!$.editable||!G||!W(G,$)||(C.value=null,w.value={row:x,cell:T,value:String($.value??"")},L.value={row:x,cell:T},window.addEventListener("pointerup",D,{once:!0}))}function s1(x,T){w.value&&(L.value={row:x,cell:T})}function V(x,T){if(!w.value||!L.value)return!1;const $=Math.min(w.value.row,L.value.row),G=Math.max(w.value.row,L.value.row),Q=Math.min(w.value.cell,L.value.cell),N=Math.max(w.value.cell,L.value.cell);return x>=$&&x<=G&&T>=Q&&T<=N}function X(x,T){if(!V(x,T)||!w.value||!L.value)return{};const $=Math.min(w.value.row,L.value.row),G=Math.max(w.value.row,L.value.row),Q=Math.min(w.value.cell,L.value.cell),N=Math.max(w.value.cell,L.value.cell);return{"w-spreadsheet__cell--fill-range":!0,"w-spreadsheet__cell--fill-top":x===$,"w-spreadsheet__cell--fill-bottom":x===G,"w-spreadsheet__cell--fill-left":T===Q,"w-spreadsheet__cell--fill-right":T===N}}function z(x,T){const $=j(x,T);return{"w-spreadsheet__cell--fill-completed":!!C.value?.cells.has($),"w-spreadsheet__cell--fill-source":C.value?.source===$}}function D(){if(!w.value||!L.value)return;const x=w.value,T=L.value,$=Math.min(x.row,T.row),G=Math.max(x.row,T.row),Q=Math.min(x.cell,T.cell),N=Math.max(x.cell,T.cell),H=new Set,R=M.value[x.row],c1=R?.cells[x.cell];for(let p1=$;p1<=G;p1++){const x1=M.value[p1];if(x1)for(let M1=Q;M1<=N;M1++){const w1=x1.cells[M1];w1?.editable&&(H.add(j(x1,w1)),s("cell-change",{rowKey:x1.key,cellKey:w1.key,value:x.value,row:x1,cell:w1}))}}w.value=null,L.value=null,C.value=R&&c1?{cells:H,source:j(R,c1)}:null}function K(x){let T=x+1,$="";for(;T>0;)T-=1,$=String.fromCharCode(65+T%26)+$,T=Math.floor(T/26);return $}function e1(x){return[`w-spreadsheet__cell--${x.variant||"default"}`,`w-spreadsheet__cell--${x.align||"left"}`,`w-spreadsheet__cell--tone-${x.tone||"default"}`,{"w-spreadsheet__cell--wrap":!!x.wrap},x.class||""]}function r1(x,T,$){const G=$.target.value;s("cell-change",{rowKey:x.key,cellKey:T.key,value:G,row:x,cell:T})}function h1(x){const $=x.currentTarget.previousElementSibling;$?.focus(),$?.showPicker?.()}return(x,T)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"frameRef",ref:E,class:e.normalizeClass(["w-spreadsheet-frame",{"w-spreadsheet-frame--expanded":c.value}])},[c.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"w-spreadsheet-frame__backdrop","aria-label":"Restore spreadsheet",onClick:T[0]||(T[0]=$=>F(!1))})):e.createCommentVNode("",!0),e.createElementVNode("div",q0,[n.expandable&&(n.showExpandButton!==!1||c.value)||n.downloadable&&(n.showDownloadButton!==!1||c.value)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["w-spreadsheet-frame__toolbar",{"w-spreadsheet-frame__toolbar--hover":n.actionsOnHover&&!c.value}])},[c.value&&x.$slots["expanded-header"]?(e.openBlock(),e.createElementBlock("div",Q0,[e.renderSlot(x.$slots,"expanded-header")])):e.createCommentVNode("",!0),x.$slots["toolbar-status"]?(e.openBlock(),e.createElementBlock("div",J0,[e.renderSlot(x.$slots,"toolbar-status")])):e.createCommentVNode("",!0),e.renderSlot(x.$slots,"toolbar"),n.downloadable&&(n.showDownloadButton!==!1||c.value)?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"w-spreadsheet-frame__expand",title:"Download spreadsheet","aria-label":"Download spreadsheet",onClick:p},[e.createVNode(e.unref(g.Download),{size:16})])):e.createCommentVNode("",!0),n.expandable&&(n.showExpandButton!==!1||c.value)?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"w-spreadsheet-frame__expand",title:c.value?"Restore spreadsheet":"Expand spreadsheet","aria-label":c.value?"Restore spreadsheet":"Expand spreadsheet",onClick:T[1]||(T[1]=$=>F(!c.value))},[c.value?(e.openBlock(),e.createBlock(e.unref(g.Minimize),{key:0,size:16})):(e.openBlock(),e.createBlock(e.unref(g.Expand),{key:1,size:16}))],8,X0)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0),n.loading?(e.openBlock(),e.createElementBlock("div",G0,[e.createVNode(O1),T[2]||(T[2]=e.createElementVNode("span",null,"Preparing sales estimate…",-1))])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["w-spreadsheet",{"w-spreadsheet--with-column-axis":l.value}]),style:e.normalizeStyle({maxHeight:c.value?"calc(100vh - 96px)":n.maxHeight})},[e.createElementVNode("table",{class:e.normalizeClass(["w-spreadsheet__table",{"w-spreadsheet__table--sticky-columns":m.value}]),style:e.normalizeStyle({minWidth:n.minWidth})},[e.createElementVNode("colgroup",null,[a.value?(e.openBlock(),e.createElementBlock("col",_0)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,$=>(e.openBlock(),e.createElementBlock("col",{key:$.key,style:e.normalizeStyle({width:$.width})},null,4))),128))]),l.value?(e.openBlock(),e.createElementBlock("thead",e3,[e.createElementVNode("tr",null,[a.value?(e.openBlock(),e.createElementBlock("th",n3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columns,($,G)=>(e.openBlock(),e.createElementBlock("th",{key:$.key,class:"w-spreadsheet__axis"},e.toDisplayString($.label||K(G)),1))),128))])])):e.createCommentVNode("",!0),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,($,G)=>(e.openBlock(),e.createElementBlock("tr",{key:$.key,class:e.normalizeClass({"w-spreadsheet__row--sticky":$.sticky})},[a.value?(e.openBlock(),e.createElementBlock("th",t3,e.toDisplayString(G+1),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.cells,(Q,N)=>(e.openBlock(),e.createElementBlock("td",{key:Q.key,class:e.normalizeClass(["w-spreadsheet__cell",[e1(Q),{"w-spreadsheet__cell--sortable":A(Q),"w-spreadsheet__cell--sticky":U($,N),"w-spreadsheet__cell--sticky-first":O($,N),"w-spreadsheet__cell--active":W($,Q)},X(G,N),z($,Q)]]),colspan:Q.colspan||1,title:Q.title,style:e.normalizeStyle(i1($,N)),tabindex:A(Q)?0:void 0,onClick:H=>S(Q),onKeydown:[e.withKeys(e.withModifiers(H=>S(Q),["prevent"]),["enter"]),e.withKeys(e.withModifiers(H=>S(Q),["prevent"]),["space"])],onPointerenter:H=>s1(G,N),onPointerdown:H=>J($,Q)},[e.renderSlot(x.$slots,`cell-${Q.key}`,{row:$,cell:Q,rowIndex:G},()=>[Q.editable?(e.openBlock(),e.createElementBlock("div",c3,[e.createElementVNode("input",{class:e.normalizeClass(["w-spreadsheet__input",{"w-spreadsheet__input--date":Q.inputType==="date"}]),type:Q.inputType||"text",value:Q.value??"",min:Q.min,placeholder:Q.placeholder,onInput:H=>r1($,Q,H)},null,42,a3),Q.inputType==="date"?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"w-spreadsheet__calendar","aria-label":"Choose date",title:"Choose date",onClick:h1},[e.createVNode(e.unref(g.CalendarDays),{size:16})])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(Q.value??""),1)],64))]),A(Q)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.value===Q.key?h.value==="asc"?e.unref(g.ChevronUp):e.unref(g.ChevronDown):e.unref(g.ChevronsUpDown)),{key:0,class:"w-spreadsheet__sort-icon",size:14})):e.createCommentVNode("",!0),n.fillHandle&&Q.editable&&W($,Q)?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"w-spreadsheet__fill-handle","aria-label":"Fill adjacent cells",title:"Drag to fill adjacent cells",onPointerdown:e.withModifiers(H=>l1(G,N,Q),["stop","prevent"])},null,40,o3)):e.createCommentVNode("",!0)],46,l3))),128))],2))),128))])],6)],6))])],2))}}),b1=(n,d)=>{const t=n.__vccOpts||n;for(const[o,s]of d)t[o]=s;return t},i3={},s3={class:"min-w-40 rounded-lg bg-white p-1.5 shadow-md shadow-zinc-900/5 dark:bg-zinc-700 dark:shadow-black/20"};function d3(n,d){return e.openBlock(),e.createElementBlock("div",s3,[e.renderSlot(n.$slots,"default")])}const c2=b1(i3,[["render",d3]]),u3=["disabled"],L1=e.defineComponent({__name:"WActionMenuItem",props:{danger:{type:Boolean},disabled:{type:Boolean}},emits:["click"],setup(n,{emit:d}){const t=d;return(o,s)=>(e.openBlock(),e.createElementBlock("button",{type:"button",disabled:n.disabled,onClick:s[0]||(s[0]=l=>t("click",l)),class:e.normalizeClass(["flex h-8 w-full items-center gap-2 rounded-md px-2 text-left font-medium transition disabled:cursor-not-allowed disabled:opacity-40",n.danger?"text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30":"text-zinc-600 hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-100 dark:hover:bg-zinc-600 dark:hover:text-white"])},[e.renderSlot(o.$slots,"default")],10,u3))}}),w2={light:{trendPositive:"#15803D",trendNegative:"#DB2777",canvas:"#F8F8F8",surface:"#FFFFFF",input:"#FFFFFF",raised:"#F2F3EF",popover:"#FFFFFF",border:"rgb(32 33 29 / 0.07)",borderHover:"rgb(32 33 29 / 0.16)",text:"#20211D",muted:"#64675C",dim:"#707467",accent:"#85C531",onAccent:"#17210B",primary:"#171717",primaryHover:"#303030",onPrimary:"#FFFFFF",secondary:"#EFEFEF",secondaryHover:"#E3E3E3",onSecondary:"#20211D",secondaryShadow:"none",switchOn:"linear-gradient(35deg, #32dc08 0%, #9de400 48%, #e9e600 100%)",switchOff:"#D4D4D8",switchDisabled:"#E4E4E7",switchThumb:"#FFFFFF",focusRing:"color-mix(in srgb, var(--wpic-accent) 18%, transparent)",positive:"#85C531",negative:"#B94238"},dark:{trendPositive:"#86EFAC",trendNegative:"#FDA4AF",canvas:"#090A05",surface:"#151515",input:"#151515",raised:"#2A2A28",popover:"#1F201D",border:"rgb(255 255 255 / 0.06)",borderHover:"rgb(255 255 255 / 0.14)",text:"#F5F5F5",muted:"#B4B4B4",dim:"#969696",accent:"#85C531",onAccent:"#17210B",primary:"#FFFFFF",primaryHover:"#E8E8E8",onPrimary:"#171717",secondary:"linear-gradient(180deg, #3A3B36, #30312D)",secondaryHover:"linear-gradient(180deg, #40413B, #353630)",onSecondary:"#F5F5F5",secondaryShadow:"inset 0 1px 0 rgb(255 255 255 / 0.15), 0 1px 2px rgb(0 0 0 / 0.12)",switchOn:"linear-gradient(35deg, #32dc08 0%, #9de400 48%, #e9e600 100%)",switchOff:"#343530",switchDisabled:"#252525",switchThumb:"#FFFFFF",focusRing:"color-mix(in srgb, var(--wpic-accent) 18%, transparent)",positive:"#85C531",negative:"#F0A09A"}},m3={light:["#3B73E1","#0891A6","#8B5CD6","#C58A16","#D64D79","#527FA8"],dark:["#7C9FE0","#5FB8C4","#AF94D5","#D8B26A","#D88FA5","#94A8BD"]};function B2(n,d={}){const t={...w2[n],...d},o={};for(const[s,l]of Object.entries(t))o[`--wpic-${s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`)}`]=l;return Object.assign(o,{"--bg-main":t.canvas,"--bg-card":t.surface,"--bg-input":t.input,"--border-subtle":t.border,"--border-strong":t.border,"--border-hover":t.borderHover,"--text-main":t.text,"--text-muted":t.muted,"--text-dim":t.dim,"--wpic-primary":t.accent,"--wpic-primary-hover":t.accent,"--wpic-control-height":"36px","--wpic-table-border":n==="light"?`color-mix(in srgb, ${t.text} 11.5%, ${t.surface})`:t.border,"--wpic-segment-active":n==="dark"?t.secondaryHover:t.surface,"--wpic-segment-shadow":n==="dark"?t.secondaryShadow:`inset 0 0 0 1px ${t.border}, 0 1px 2px rgb(0 0 0 / 0.08)`,"--wpic-button-primary":t.primary,"--wpic-button-primary-hover":t.primaryHover}),o}const M2=Symbol("wpic-theme");function T1(){return e.inject(M2,e.computed(()=>null))}const h3=["data-wpic-theme"],y1=e.defineComponent({__name:"WPopover",props:{open:{type:Boolean},anchor:{},placement:{},width:{},minWidth:{},height:{},minHeight:{},maxHeight:{},panelScroll:{type:Boolean,default:!0},offset:{},matchAnchorWidth:{type:Boolean},freezePositionOnOpen:{type:Boolean,default:!0},flip:{type:Boolean,default:!0},autoPlacement:{type:Boolean},shiftCrossAxis:{type:Boolean},zIndex:{default:9999},extraPanels:{}},emits:["close"],setup(n,{emit:d}){const t=n,o=T1(),s=d,l=Symbol.for("wpic-ui-popover-descendants"),a=e.inject(l,null),m=new Set;e.provide(l,{add(B){m.add(B),a?.add(B)},remove(B){m.delete(B),a?.remove(B)}});const f=e.computed(()=>{const B=t.anchor;return B?e.isRef(B)?B.value:B:null}),h=e.ref(null),c=e.ref(null),E=e.computed(()=>c.value??t.placement??"bottom-start"),w=e.computed(()=>{const B=[n1.offset(t.offset??6)];return c.value||(t.autoPlacement?B.push(n1.autoPlacement({alignment:"start"})):t.flip&&B.push(n1.flip({crossAxis:!t.shiftCrossAxis}))),B.push(n1.shift({padding:t.autoPlacement?8:4,crossAxis:t.autoPlacement||t.shiftCrossAxis})),B.push(n1.size({padding:8,apply({availableHeight:U,rects:O,elements:i1}){const j=Math.max(U-8,50),W={maxHeight:t.maxHeight?`min(${t.maxHeight}, ${j}px)`:`${j}px`,overflowY:t.panelScroll?"auto":"hidden"};if(t.height&&(W.height=`min(${t.height}, ${j}px)`),t.minHeight&&(W.minHeight=`min(${t.minHeight}, ${j}px)`),t.matchAnchorWidth){const l1=`${O.reference.width}px`;W.width=l1,W.minWidth=l1}Object.assign(i1.floating.style,W)}})),B}),{floatingStyles:L,placement:b,update:C,isPositioned:p}=n1.useFloating(f,h,{placement:E,strategy:"fixed",open:e.computed(()=>t.open),whileElementsMounted:n1.autoUpdate,middleware:w}),F=e.computed(()=>{const B=b.value;return B.startsWith("top")?"bottom":B.startsWith("bottom")?"top":B.startsWith("left")?"right":B.startsWith("right")?"left":"top"}),q=B=>{const U=B.target,O=f.value,i1=h.value;i1&&i1.contains(U)||[...m].some(j=>j.contains(U))||O&&O.contains(U)||t.extraPanels?.some(j=>j?.contains(U))||s("close")},t1=B=>{if(B.key!=="Escape"||!t.open||[...m].some(O=>O.isConnected&&O.style.display!=="none"))return;B.preventDefault(),B.stopImmediatePropagation(),s("close");const U=f.value;U?.matches("button, input, [tabindex]")?U.focus():U?.querySelector("button, input, [tabindex]")?.focus()};let P=!1,Z=!1;function M(){Z||(document.addEventListener("pointerdown",q,!0),document.addEventListener("keydown",t1,!0),Z=!0)}function A(){Z&&(document.removeEventListener("pointerdown",q,!0),document.removeEventListener("keydown",t1,!0),Z=!1)}e.watch(()=>t.open,B=>{B?e.nextTick(()=>{P||!t.open||(t.autoPlacement&&h.value&&(h.value.style.maxHeight=""),C(),M())}):(c.value=null,A())},{immediate:!0}),e.watch(h,(B,U)=>{U&&a?.remove(U),B&&a?.add(B)}),e.watch(p,B=>{B&&t.open&&t.freezePositionOnOpen&&!c.value&&(c.value=b.value)}),e.onBeforeUnmount(()=>{P=!0,A(),h.value&&a?.remove(h.value)});const S=e.computed(()=>({...t.matchAnchorWidth?{}:{width:t.width??"auto"},...t.minWidth?{minWidth:t.minWidth}:{},transformOrigin:F.value,zIndex:t.zIndex}));return(B,U)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",class:"wpic-popover"},[e.withDirectives(e.createElementVNode("div",{ref_key:"floatingEl",ref:h,"data-wpic-theme":e.unref(o)?.mode,class:e.normalizeClass([{"wpic-theme":e.unref(o),dark:e.unref(o)?.mode==="dark"},"wpic-popover-panel flex flex-col bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl shadow-xl dark:shadow-black/40 overflow-hidden"]),style:e.normalizeStyle([e.unref(o)?.variables,e.unref(L),S.value])},[e.renderSlot(B.$slots,"default")],14,h3),[[e.vShow,n.open]])]))}}),p3={key:0,class:"fixed right-0 top-0 z-[9997] flex h-full w-20 items-center justify-center border-l-2 border-[var(--wpic-primary)] bg-[var(--wpic-primary)]/10 text-[var(--wpic-primary)] pointer-events-none"},v3=["data-variant","data-maximized"],f3=["title"],g3={class:"min-w-0 flex-1 px-2 text-center"},C3={class:"truncate font-medium text-zinc-700 dark:text-zinc-200"},k3={key:0,class:"truncate text-zinc-500 dark:text-zinc-400"},z3={class:"flex shrink-0 items-center gap-1"},b3=["title"],y3=["title"],x3=["title"],w3=["title"],B3={class:"flex h-11 shrink-0 items-center justify-between px-3"},M3={class:"font-medium text-zinc-700 dark:text-zinc-200"},V3=["title"],E3={class:"space-y-2 px-3 pb-3"},N3={class:"truncate"},S3={class:"flex-1 overflow-y-auto overflow-x-visible px-2 pb-3"},L3={class:"mb-2 flex h-7 items-center justify-between px-2 font-medium text-zinc-500 dark:text-zinc-400"},D3={class:"truncate"},F3=["title"],$3={class:"space-y-0.5"},A3={key:0,class:"rounded-lg border border-dashed border-zinc-200 px-2 py-2 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400"},T3=["onMouseenter"],H3=["onClick"],P3={class:"min-w-0 flex-1 truncate"},j3={key:0,class:"shrink-0 text-zinc-400"},W3={key:0,class:"px-3 py-2 text-zinc-400 dark:text-zinc-500"},R3=["onPointerdown","onClick"],I3={class:"min-w-0 flex-1 truncate"},Z3={class:"shrink-0 text-zinc-400"},U3={class:"mt-4"},K3={class:"flex h-7 items-center px-2 font-medium text-zinc-500 dark:text-zinc-400"},O3={class:"truncate"},Y3={class:"space-y-0.5"},q3={key:0,class:"rounded-lg border border-dashed border-zinc-200 px-2 py-2 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400"},Q3=["onPointerdown","onClick"],J3={class:"block truncate"},X3={class:"shrink-0 text-zinc-400"},G3=["onClick"],_3=["onPointerenter","onMouseenter"],e4={class:"truncate"},n4={class:"flex min-h-0 flex-1"},t4={class:"flex min-w-0 flex-1 flex-col"},l4={key:0,class:"flex h-full flex-col items-center justify-center px-5 text-center text-zinc-500 dark:text-zinc-400"},c4={class:"font-medium"},a4={key:1,class:"flex h-full flex-col items-center justify-center px-5 text-center"},o4={class:"mb-3 flex h-11 w-11 items-center justify-center rounded-xl bg-zinc-100 text-zinc-500 dark:bg-zinc-700 dark:text-zinc-300"},r4={class:"font-semibold text-zinc-800 dark:text-zinc-100"},i4={key:0,class:"mt-1 max-w-xs text-zinc-500 dark:text-zinc-400"},s4={key:2,class:"space-y-4"},d4={class:"max-w-[82%]"},u4=["src","alt"],m4={class:"max-w-40 truncate"},h4={key:0,class:"shrink-0 text-zinc-400"},p4={key:0,class:"flex items-center gap-2 text-zinc-500 dark:text-zinc-400"},v4={key:1,class:"wpic-chat-loading-card",role:"status","aria-label":"Generating image"},f4=["innerHTML","onClick"],g4=["href","onClick"],C4=["src"],k4=["title","aria-label","onClick"],z4=["title","aria-label","onClick"],b4=["title","onClick"],y4=["onClick"],x4=["title","onClick"],w4={key:0,class:"mb-2 flex flex-wrap justify-end gap-1.5"},B4=["src","alt"],M4={class:"max-w-40 truncate"},V4={key:0,class:"shrink-0 text-zinc-400"},E4={key:1,class:"shrink-0 text-zinc-400"},N4=["title","onClick"],S4={class:"wpic-chat-panel__composer rounded-xl border border-zinc-200 bg-zinc-50 transition-colors focus-within:border-[var(--wpic-primary)]/50 dark:border-zinc-700 dark:bg-zinc-700"},L4={key:0,class:"mx-2 mt-2 overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-600"},D4=["onMousedown"],F4={class:"min-w-0 truncate font-medium text-zinc-900 dark:text-zinc-100"},$4={key:0,class:"max-w-32 shrink-0 truncate text-xs text-zinc-500 dark:text-zinc-400"},A4=["accept"],T4=["value","placeholder","disabled"],H4={class:"flex items-center justify-between px-2 pb-2"},P4=["disabled","title"],j4=["title"],W4=["disabled","title"],z2=80,R4=e.defineComponent({__name:"WChatPanel",props:{open:{type:Boolean},messages:{},mentionItems:{default:()=>[]},projects:{default:()=>[]},sessions:{default:()=>[]},modelValue:{default:""},title:{default:"Chat"},subtitle:{default:""},selectedProjectId:{default:null},selectedSessionId:{default:null},placeholder:{default:"Ask anything..."},emptyTitle:{default:"How can I help?"},emptyDescription:{default:""},noProjectsLabel:{default:"No projects yet"},noConversationsLabel:{default:"No conversations yet"},allLabel:{default:"All"},recentLabel:{default:"Recent"},projectsLabel:{default:"Projects"},conversationsLabel:{default:"Conversations"},sendLabel:{default:"Send"},newLabel:{default:"New chat"},newProjectLabel:{default:"New project"},newConversationLabel:{default:"New conversation"},renameProjectLabel:{default:"Rename project"},renameConversationLabel:{default:"Rename conversation"},deleteProjectLabel:{default:"Delete project"},deleteConversationLabel:{default:"Delete conversation"},clearLabel:{default:"Clear"},copyLabel:{default:"Copy"},copiedLabel:{default:"Copied"},newChatFromMessageLabel:{default:"Start new chat from this message"},attachFilesLabel:{default:"Attach files"},removeAttachmentLabel:{default:"Remove attachment"},stopLabel:{default:"Stop"},applyPromptLabel:{default:"Apply prompt"},applyAllLabel:{default:"Apply all"},applySettingLabel:{default:"Apply setting"},thinkingLabel:{default:"Thinking..."},dockLabel:{default:"Dock"},undockLabel:{default:"Undock"},closeLabel:{default:"Close"},helpfulLabel:{default:"Helpful"},notHelpfulLabel:{default:"Not helpful"},attachments:{default:()=>[]},accept:{default:""},customAttachmentPicker:{type:Boolean,default:!1},showNavigator:{type:Boolean,default:!0},hideNewConversation:{type:Boolean,default:!1},hideClear:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},cancellable:{type:Boolean,default:!1},docked:{type:Boolean,default:!1},maximized:{type:Boolean,default:!1},maximizedMargin:{default:20},width:{default:420},height:{default:560},x:{default:-1},y:{default:-1},topOffset:{default:0},minWidth:{default:340},minHeight:{default:400},zIndex:{default:80},variant:{default:"default"}},emits:["close","send","clear","new","new-project","new-conversation","select-project","select-session","rename-project","rename-session","delete-project","delete-session","move-session","edit-message","new-chat-from-message","message-feedback","apply-message-proposal","navigate","cancel","attach","files-selected","remove-attachment","update:modelValue","update:docked","update:maximized","update:width","update:height","update:x","update:y"],setup(n,{emit:d}){const t=n,o=d,s=e.useSlots(),l=e.ref(null),a=e.ref(null),m=e.ref(null),f=e.ref(null),h=e.ref(null),c=e.ref(null),E=e.ref(0),w=e.ref(0),L=e.ref(!1),b=e.ref(null),C=e.ref(null);let p=null;const F=e.ref(!1),q=e.ref(!1),t1=e.ref(!1);e.ref(new Set);const P=e.ref(null),Z=e.ref(null),M=e.ref({}),A=e.ref(null);let S=null,B=null;function U(){B?.disconnect(),B=null;const r=a.value,i=h.value;if(!r||!i||typeof ResizeObserver>"u")return;const u=()=>i.style.setProperty("--wpic-chat-footer-height",`${r.getBoundingClientRect().height}px`);u(),B=new ResizeObserver(u),B.observe(r)}const O=e.computed(()=>A.value?[]:t.messages.filter(r=>r.role!=="system")),i1=e.computed(()=>t.loading||A.value!==null),j=e.computed(()=>t.modelValue.trim().length>0&&!t.loading),J=e.computed(()=>t.attachments.length>0),W=e.computed(()=>{const r=t.modelValue.slice(0,w.value),i=r.match(/(?:^|\s)@([^\s@]*)$/);return i?{start:r.length-i[0].length+(i[0].startsWith(" ")?1:0),query:i[1].toLowerCase()}:null}),l1=e.computed(()=>{const r=W.value;if(!r)return[];const i=r.query;return t.mentionItems.filter(u=>u.label.toLowerCase().includes(i)).slice(0,6)}),s1=e.computed(()=>t.showNavigator&&L.value),V=e.computed(()=>t.selectedProjectId??null),X=e.computed(()=>t.sessions.filter(r=>!r.projectId)),z=e.computed(()=>{const r=new Map;for(const i of t.projects)r.set(i.id,[]);for(const i of t.sessions){if(!i.projectId)continue;const u=r.get(i.projectId);u&&u.push(i)}return r});function D(r){const i=r.toLowerCase();if(i.includes("doubao-seedance-1-5-pro-251215")||i.includes("doubao seedance 1.5")||i.includes("seedance 1.5")||i.includes("seedance video"))return"jimeng:doubao-seedance-1-5-pro-251215";if(i.includes("imagen 4")||i.includes("imagen-4"))return"google:imagen-4.0-generate-001";if(i.includes("gpt-image-1")||i.includes("gpt image 1"))return"openai:gpt-image-1";if(i.includes("gpt-image-2")||i.includes("gpt image 2"))return"openai:gpt-image-2";if(i.includes("doubao-seedream-4-5-251128"))return"jimeng:doubao-seedream-4-5-251128";if(i.includes("doubao-seedream-4-0-250828"))return"jimeng:doubao-seedream-4-0-250828";if(i.includes("doubao seedream 5")||i.includes("seedream 5")||i.includes("doubao seedream 4.5")||i.includes("seedream 4.5"))return"jimeng:doubao-seedream-4-5-251128";if(i.includes("doubao seedream 4")||i.includes("seedream 4"))return"jimeng:doubao-seedream-4-0-250828";if(i.includes("auto"))return"auto";const u=r.match(/\b([a-z][a-z0-9_-]+):([a-z0-9._-]+)\b/i);if(u)return`${u[1].toLowerCase()}:${u[2]}`}function K(r){if(r!=="auto"){if(r.includes("seedance"))return"video";if(r.includes("gpt-image")||r.includes("imagen")||r.includes("seedream")||r.includes("jimeng:"))return"image"}}function e1(r){const i=[],u=new Set,k=/\b(gpt[-\s]?image[-\s]?[12]|imagen\s*4|doubao\s+seedance\s+1\.5(?:\s+pro)?|seedance\s+1\.5(?:\s+pro)?|doubao\s+seedream\s+(?:5(?:\.0)?|4\.5|4)|seedream\s+(?:5(?:\.0)?|4\.5|4)|[a-z][a-z0-9_-]+:[a-z0-9._-]+|auto)\b/gi;for(const v of r.matchAll(k)){const y=v[1],I=D(y);!I||u.has(I)||(u.add(I),i.push({label:y,value:I}))}return i}function r1(r,i){return r.match(new RegExp(`${i}=["']([^"']+)["']`,"i"))?.[1]}function h1(r){const i={};for(const k of r.matchAll(/\[SETTING\s+([^\]]+)\]([\s\S]*?)\[\/SETTING\]/gi)){const v=k[1]??"",y=r1(v,"key"),I=r1(v,"value")??k[2]?.trim();if(!(!y||!I))if(y==="duration"||y==="fps"||y==="count"){const Y=Number(I);Number.isFinite(Y)&&(i[y]=Y)}else if(y==="model"){const Y=D(I)??D(k[2]?.trim()??"");Y&&(i.model=Y)}else(y==="aspect"||y==="resolution"||y==="format")&&(i[y]=I)}const u=r.split(/\r?\n/).map(k=>k.replace(/^[\s>*-]+/,"").trim()).filter(Boolean);for(const k of u){const v=k.toLowerCase();if(/(supporte|supports?|disponible|available|dur[eé]es?\s*:|ratios?\s*:|jusqu['’]?à|up to)/i.test(v))continue;const y=k.split(":").slice(1).join(":").trim()||k,I=y.match(/\b(\d{1,2}:\d{1,2})\b/);(v.includes("format")||v.includes("aspect")||v.includes("ratio"))&&I&&(i.aspect=I[1]);const Y=y.match(/\b([1248]K)\b/i);(v.includes("résolution")||v.includes("resolution"))&&Y&&(i.resolution=Y[1].toUpperCase());const _=y.match(/\b(\d{1,3})\s*(?:s|sec|secondes?|seconds?)\b/i);(v.includes("durée")||v.includes("duration"))&&_&&(i.duration=Number(_[1]));const a1=y.match(/\b(\d{1,3})\s*fps\b/i);v.includes("fps")&&a1&&(i.fps=Number(a1[1]));const o1=y.match(/\b(\d{1,2})\b/);if((v.includes("count")||v.includes("nombre")||v.includes("variantes"))&&o1&&(i.count=Number(o1[1])),v.includes("modèle")||v.includes("modele")||v.includes("model")){const v1=D(y);v1&&(i.model=v1)}v.includes("jpg")||v.includes("jpeg")?i.format="jpg":v.includes("png")?i.format="png":v.includes("webp")&&(i.format="webp")}return Object.keys(i).length?i:void 0}function x(r){const i=r.match(/\[TASK(?:\s+([^\]]+))?\](?:([\s\S]*?)\[\/TASK\])?/i);if(i){const k=(r1(i[1]??"","value")??i[2]?.trim())?.toLowerCase();if(["image","video","audio","text"].includes(String(k)))return k}const u=r.split(/\r?\n/).map(k=>k.replace(/^[\s>*-]+/,"").trim()).filter(Boolean);for(const k of u){const v=k.toLowerCase(),y=k.split(":").slice(1).join(":").trim().toLowerCase()||v;if(/(task|type|mode|surface|format|réglage|reglage|setting)/i.test(v)){if(/\baudio\b|subtitles?|sous-titres?|transcri|tts|voice|voix/.test(y))return"audio";if(/\bvid[eé]o\b|\bvideo\b|\bfps\b|duration|dur[eé]e/.test(y))return"video";if(/\bimage\b|photo|visuel|illustration|aspect|ratio|resolution|résolution/.test(y))return"image";if(/\btext\b|texte|copy|caption|script/.test(y))return"text"}}}function T(r){const i=r.match(/\[PROMPT\]([\s\S]*?)\[\/PROMPT\]/i)?.[1];if(i){const _=M1(i).trim().replace(/^["“]|["”]$/g,"");if(_)return _}const u=r.replace(/\r\n/g,`
|
|
3
3
|
`).split(`
|
|
4
4
|
`),k=[];let v=!1,y=!1,I=!1;for(const _ of u){const a1=_.trim().replace(/^[\s>*-]+/,"").replace(/^#{1,6}\s+/,"").replace(/^\*\*|\*\*$/g,"").trim();if(y){if(/^```/.test(a1))break;k.push(_);continue}if(!v){const o1=a1.match(/^(?:(?:voici|essayez|utilisez|use|try)\s+(?:ce\s+)?(?:prompt)|prompt\s+(?:modifi[eé]|am[eé]lior[eé]|propos[eé]|recommand[eé])|prompt)\s*:\s*(.*)$/i);if(!o1){I||=/\bprompt\b/i.test(a1),I&&/^```/.test(a1)&&(v=!0,y=!0);continue}v=!0,o1[1]?.trim()&&k.push(o1[1].trim());continue}if(/^(?:r[eé]glages?(?:\s+recommand[eé]s?)?|settings?|mod[eè]le|model)\s*:/i.test(a1))break;k.push(_)}return M1(k.join(`
|
|
5
5
|
`)).trim().replace(/^["“]|["”]$/g,"")||void 0}function $(r){return/\[PROMPT\]([\s\S]*?)\[\/PROMPT\]/i.test(r)}function G(r){return/\[TASK(?:\s+[^\]]+)?\]/i.test(r)}function Q(r){const i=r.match(/\[TASK(?:\s+([^\]]+))?\]([\s\S]*?)\[\/TASK\]/i),u=`${i?.[1]??""} ${i?.[2]??""}`.toLowerCase();return $(r)&&(/\bimage\b/.test(u)||!G(r))}function N(r){return/\[(?:TASK|PROMPT|SETTING)\b/i.test(r)}function H(r){const i=k=>Array.isArray(k)?k.flatMap(v=>{if(!v||typeof v!="object")return[];const y=v,I=typeof y.url=="string"?y.url:null;return I?[{type:typeof y.type=="string"?y.type:"image",url:I,posterUrl:typeof y.posterUrl=="string"?y.posterUrl:null,width:typeof y.width=="number"?y.width:null,height:typeof y.height=="number"?y.height:null,generationId:typeof y.generationId=="string"?y.generationId:null,href:typeof y.href=="string"?y.href:null}]:[]}):[],u=r.metadata?.generatedMedia;return i(u).filter(k=>k.type==="image"||!k.type)}function R(r){const i=r.metadata?.attachments;return Array.isArray(i)?i.flatMap((u,k)=>{if(!u||typeof u!="object")return[];const v=u,y=v.metadata&&typeof v.metadata=="object"?v.metadata:{},I=typeof v.name=="string"&&v.name.trim()?v.name.trim():`Attachment ${k+1}`;return[{id:typeof v.id=="string"?v.id:`${r.id??"message"}-attachment-${k}`,name:I,mimeType:typeof v.mimeType=="string"?v.mimeType:null,bytes:typeof v.bytes=="number"?v.bytes:null,status:"ready",displayUrl:typeof v.displayUrl=="string"?v.displayUrl:typeof y.displayUrl=="string"?y.displayUrl:null,publicUrl:typeof v.publicUrl=="string"?v.publicUrl:typeof y.publicUrl=="string"?y.publicUrl:null,assetId:typeof v.assetId=="string"?v.assetId:null,mediaItemId:typeof v.mediaItemId=="string"?v.mediaItemId:null,metadata:y}]}):[]}function c1(r){const i=r.metadata&&typeof r.metadata=="object"?r.metadata:{},u=r.mimeType??"",k=typeof i.kind=="string"?i.kind:"",v=r.displayUrl??(typeof i.displayUrl=="string"?i.displayUrl:null);return!v||!u.startsWith("image/")&&k!=="image"?null:v}function p1(r){if(r.role!=="assistant"||!r.streaming)return!1;const i=r.content.trim();return i==="Generating image..."||N(i)}function x1(r){return r.replace(/\[PROMPT\]([\s\S]*?)\[\/PROMPT\]/gi,"$1").replace(/\[SETTING\s+[^\]]*\]([\s\S]*?)\[\/SETTING\]/gi,"$1").replace(/\[TASK(?:\s+[^\]]*)?\]([\s\S]*?)\[\/TASK\]/gi,"").replace(/^\s*\[TASK(?:\s+[^\]]*)?\]\s*$/gim,"")}function M1(r){return r.replace(/\[PROMPT\]|\[\/PROMPT\]/gi,"").replace(/\[SETTING\s+[^\]]*\]|\[\/SETTING\]/gi,"").replace(/\[TASK\s+[^\]]*\]|\[\/TASK\]/gi,"").split(`
|
package/dist/wpic-ui.js
CHANGED
|
@@ -1139,6 +1139,7 @@ const P4 = ["data-wpic-theme"], n2 = /* @__PURE__ */ X({
|
|
|
1139
1139
|
freezePositionOnOpen: { type: Boolean, default: !0 },
|
|
1140
1140
|
flip: { type: Boolean, default: !0 },
|
|
1141
1141
|
autoPlacement: { type: Boolean },
|
|
1142
|
+
shiftCrossAxis: { type: Boolean },
|
|
1142
1143
|
zIndex: { default: 9999 },
|
|
1143
1144
|
extraPanels: {}
|
|
1144
1145
|
},
|
|
@@ -1158,7 +1159,7 @@ const P4 = ["data-wpic-theme"], n2 = /* @__PURE__ */ X({
|
|
|
1158
1159
|
return H ? X0(H) ? H.value : H : null;
|
|
1159
1160
|
}), p = F(null), i = F(null), j = y(() => i.value ?? t.placement ?? "bottom-start"), S = y(() => {
|
|
1160
1161
|
const H = [v2(t.offset ?? 6)];
|
|
1161
|
-
return i.value || (t.autoPlacement ? H.push(A3({ alignment: "start" })) : t.flip && H.push(m2())), H.push(f2({ padding: t.autoPlacement ? 8 : 4, crossAxis: t.autoPlacement })), H.push(
|
|
1162
|
+
return i.value || (t.autoPlacement ? H.push(A3({ alignment: "start" })) : t.flip && H.push(m2({ crossAxis: !t.shiftCrossAxis }))), H.push(f2({ padding: t.autoPlacement ? 8 : 4, crossAxis: t.autoPlacement || t.shiftCrossAxis })), H.push(
|
|
1162
1163
|
X2({
|
|
1163
1164
|
padding: 8,
|
|
1164
1165
|
apply({ availableHeight: t1, rects: c1, elements: w1 }) {
|