@optona/otofill 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +118 -3
- package/dist/otofill.js +2536 -0
- package/dist/otofill.min.js +77 -0
- package/dist/types/drivers.d.ts +9 -0
- package/dist/types/engine.d.ts +30 -0
- package/dist/types/fill-utils.d.ts +22 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/io.d.ts +33 -0
- package/dist/types/matcher.d.ts +36 -0
- package/dist/types/panel/dom.d.ts +16 -0
- package/dist/types/panel/panel.d.ts +81 -0
- package/dist/types/panel/styles.d.ts +1 -0
- package/dist/types/scanner.d.ts +30 -0
- package/dist/types/store.d.ts +42 -0
- package/dist/types/types.d.ts +69 -0
- package/dist/types/ui/element-plus.d.ts +7 -0
- package/dist/types/util.d.ts +21 -0
- package/package.json +49 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var Otofill=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},r={ı:`i`,ğ:`g`,ü:`u`,ş:`s`,ö:`o`,ç:`c`,â:`a`,î:`i`,û:`u`};function i(e){return e?e.toLocaleLowerCase(`tr`).replace(/[ığüşöçâîû]/g,e=>r[e]??e).normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,` `).trim():``}function a(e,t){if(e=i(e).replace(/ /g,``),t=i(t).replace(/ /g,``),!e||!t)return 0;if(e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let t=0;t<e.length-1;t++){let r=e.slice(t,t+2);n.set(r,(n.get(r)??0)+1)}let r=0;for(let e=0;e<t.length-1;e++){let i=t.slice(e,e+2),a=n.get(i)??0;a>0&&(n.set(i,a-1),r++)}return 2*r/(e.length+t.length-2)}function o(e){return i(e).replace(/ /g,`_`).slice(0,40)}function s(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():Date.now().toString(36)+Math.random().toString(36).slice(2,10)+Math.random().toString(36).slice(2,6)}function c(){return new Date().toISOString()}function l(e){let t=e.trim().replace(/[.+^${}()|[\]\\?]/g,`\\$&`).replace(/\*/g,`.*`);return RegExp(`^`+t+`$`,`i`)}function ee(e,t){let n=(e??[]).map(e=>e.trim()).filter(Boolean);return n.length===0||n.some(e=>{try{return l(e).test(t)}catch{return!1}})}function u(e=location){let t=e.pathname.replace(/\/\d+(?=\/|$)/g,`/*`);if(e.hash.startsWith(`#/`)){let n=e.hash.split(`?`)[0].replace(/\/\d+(?=\/|$)/g,`/*`);return`${e.origin}${t}*${n}*`}return`${e.origin}${t}*`}function te(e=location){return`${e.origin}/*`}function d(e){return/\d{3,}/.test(e)||/[0-9a-f]{8,}/i.test(e)||/^(el-id-|v-\d|:r|mui-|pv_id|react-|ember|ext-|ui-id-|__|input-\d|headlessui-|radix-|n-\d)/i.test(e)}function f(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/["\\#.:[\]()>+~*^$|=\s]/g,`\\$&`)}function p(e){if(e.id&&!d(e.id))return`#${f(e.id)}`;let t=[],n=e;for(;n&&t.length<6;){if(n!==e&&n.id&&!d(n.id)){t.unshift(`#${f(n.id)}`);break}let r=n.tagName.toLowerCase(),i=n.getAttribute(`name`);n===e&&i&&(r+=`[name="${f(i)}"]`);let a=n.parentElement;if(a){let e=n.tagName,t=Array.from(a.children).filter(t=>t.tagName===e);t.length>1&&(r+=`:nth-of-type(${t.indexOf(n)+1})`)}if(t.unshift(r),n.tagName===`FORM`||n.tagName===`BODY`)break;n=a}return t.join(` > `)}var m=e=>new Promise(t=>setTimeout(t,e)),ne=`optona-otofill`,h=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,re=new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`]),g=`.el-form-item, .ant-form-item, .n-form-item, .v-input, .q-field, .p-field, .p-float-label, .field, .form-group, .form-item, .form-field, .mb-3`,_=`label, .el-form-item__label, .ant-form-item-label, .n-form-item-label, .v-label, .q-field__label, legend`,v=e=>e.tagName.toLowerCase();function y(e){let t=v(e);if(t===`textarea`)return`textarea`;if(t===`select`)return`select`;if(t===`input`){if(e.closest(`.el-select, .el-cascader`))return`select`;if(e.closest(`.el-date-editor`))return`date`;let t=(e.getAttribute(`type`)??`text`).toLowerCase();return t===`checkbox`?`checkbox`:t===`radio`?`radio`:[`date`,`datetime-local`,`month`,`time`,`week`].includes(t)?`date`:`text`}return e.isContentEditable?`contenteditable`:`other`}function b(e){return!(!e||!e.matches?.(h)||v(e)===`input`&&re.has((e.getAttribute(`type`)??`text`).toLowerCase()))}function x(e){if(!e)return null;if(b(e))return e;let t=e.closest(`label`);if(t?.control&&b(t.control))return t.control;let n=e.closest(h);if(n&&b(n))return n;let r=e.closest(`.el-select, .el-input, .el-date-editor, .p-dropdown, .v-field, .ant-select, .n-input, .q-field`)?.querySelector(h);return r&&b(r)?r:null}function S(e){if(!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}function C(e){let t=y(e);if(t===`checkbox`||t===`radio`){if(S(e))return!0;let t=e.closest(`label`)??(e.id?e.getRootNode():null)?.querySelector?.(`label[for="${f(e.id)}"]`);return!!(t&&S(t))||!!(e.parentElement&&S(e.parentElement))}return S(e)}function w(e){return(e??``).replace(/\s+/g,` `).replace(/^[*\s]+|[*:\s]+$/g,``).trim().slice(0,80)}function T(e,t){let n=``,r=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),i;for(;i=r.nextNode();){let e=i.parentElement;!e||t.contains(i)||e.closest(`select, option, textarea, script, style, button`)||(n+=` `+i.textContent)}return w(n)}function ie(e,t){return e.getRootNode().getElementById?.(t)??e.ownerDocument.getElementById(t)}function E(e){let t=e;for(let e=0;t&&e<4;e++){let e=t.previousSibling;for(;e;){if(e.nodeType===Node.TEXT_NODE){let t=w(e.textContent);if(t)return t}else if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.matches(h)||t.querySelector(h))return``;let n=w(t.textContent);if(n)return n}e=e.previousSibling}if(t=t.parentElement,!t||t.tagName===`FORM`||t.tagName===`BODY`)break}return``}function D(e){let t=e.getAttribute(`aria-labelledby`);if(t){let n=w(t.split(/\s+/).map(t=>ie(e,t)?.textContent??``).join(` `));if(n)return n}if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${f(e.id)}"]`);if(t){let n=T(t,e);if(n)return n}}let n=e.closest(`label`);if(n){let t=T(n,e);if(t)return t}let r=w(e.getAttribute(`aria-label`));if(r)return r;let i=e.closest(g);if(i){let t=i.querySelector(_);if(t&&!t.contains(e)){let n=T(t,e);if(n)return n}}return E(e)}function O(e){let t=e.getAttribute(`name`);if(!t)return[e];let n=e.closest(`form`)??e.getRootNode();return Array.from(n.querySelectorAll(`input[type="radio"][name="${f(t)}"]`))}function k(e){if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${f(e.id)}"]`);if(t)return T(t,e)}let t=e.closest(`label`);if(t)return T(t,e);let n=e.nextSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&!w(n.textContent);)n=n.nextSibling;return w(n?.textContent)}function ae(e){let t=O(e),n=e.closest(`fieldset`)?.querySelector(`legend`);if(n)return w(n.textContent);let r=e.closest(`[role="radiogroup"]`);if(r){let t=w(r.getAttribute(`aria-label`))||(r.getAttribute(`aria-labelledby`)?w(ie(e,r.getAttribute(`aria-labelledby`))?.textContent):``);if(t)return t}let i=e.closest(g);if(i){let e=Array.from(i.querySelectorAll(_)).find(e=>!t.some(t=>e.contains(t)||t.id&&e.getAttribute(`for`)===t.id));if(e)return w(e.textContent)}let a=e.parentElement;for(;a&&!t.every(e=>a.contains(e));)a=a.parentElement;return a?E(a):``}function oe(e){let t=O(e),n=e.parentElement;for(;n&&!t.every(e=>n.contains(e));)n=n.parentElement;return n?`${p(n)} input[type="radio"]`:p(e)}function se(e){let t=e.closest(`form`);if(t)return(t.id&&!d(t.id)?t.id:``)||t.getAttribute(`name`)||void 0}function A(e,t=0){let n=y(e),r=e.getAttribute(`name`)||void 0,i=r&&!d(r)?r:void 0;return{el:e,kind:n,tag:v(e),type:e.getAttribute(`type`)?.toLowerCase()||void 0,otofill:e.getAttribute(`data-otofill`)||void 0,id:e.id&&!d(e.id)?e.id:void 0,name:i,label:(n===`radio`?ae(e):D(e))||void 0,placeholder:e.getAttribute(`placeholder`)||void 0,ariaLabel:e.getAttribute(`aria-label`)||void 0,css:n===`radio`?i?`input[type="radio"][name="${f(i)}"]`:oe(e):p(e),formKey:se(e),index:t}}function ce(e,t){e.querySelectorAll(h).forEach(e=>{b(e)&&!e.disabled&&C(e)&&t.push(e)}),e.querySelectorAll(`*`).forEach(e=>{if(e.tagName.toLowerCase()===`optona-otofill`)return;let n=e.shadowRoot;if(n&&ce(n,t),e.tagName===`IFRAME`)try{let n=e.contentDocument;n&&ce(n,t)}catch{}})}function j(e=document){let t=[];ce(e,t);let n=new Set,r=[];for(let e of t)if(y(e)===`radio`){let t=O(e);if(n.has(t[0]))continue;n.add(t[0]),r.push(A(t[0],r.length))}else r.push(A(e,r.length));return r}function le(e){let{el:t,kind:n,...r}=e;return r}function M(e,t){e.dispatchEvent(new Event(t,{bubbles:!0}))}function N(e,t){let n={key:t,code:t,bubbles:!0,cancelable:!0};e.dispatchEvent(new KeyboardEvent(`keydown`,n)),e.dispatchEvent(new KeyboardEvent(`keyup`,n))}function P(e,t){let n=Object.getPrototypeOf(e),r;for(;n&&!(r=Object.getOwnPropertyDescriptor(n,`value`));)n=Object.getPrototypeOf(n);r?.set?r.set.call(e,t):e.value=t}function ue(e){if(!e||!e.isConnected||!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}async function F(e,t=800,n=25){let r=Date.now()+t;for(;;){let t=e();if(t)return t;if(Date.now()>r)return null;await m(n)}}function de(e,t,n=e=>e.textContent??``){let r=i(t);if(r)return e.find(e=>i(n(e))===r)??e.find(e=>i(n(e)).startsWith(r))??e.find(e=>a(n(e),t)>=.85)}var fe=e=>e.split(`|`).map(e=>e.trim()).filter(Boolean);function pe(e){let t=e.trim(),n=``,r=``,i=``,a=``,o=t.match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(.*)$/);return o?[,i,r,n,a]=o:(o=t.match(/^(\d{4})[./-](\d{1,2})[./-](\d{1,2})(.*)$/))&&([,n,r,i,a]=o),n?(r=r.padStart(2,`0`),i=i.padStart(2,`0`),a=a.replace(/^T/,` `),[...new Set([`${n}-${r}-${i}${a}`,t,`${i}.${r}.${n}${a}`,`${i}/${r}/${n}${a}`,`${r}/${i}/${n}${a}`,`${n}/${r}/${i}${a}`])]):[t]}function me(e,t){let n=e=>(e.match(/\d+/g)??[]).map(Number),r=n(e),i=n(t);return i.length>0&&i.every((e,t)=>r[t]===e)}var he=e=>e.tagName===`INPUT`;function ge(e){let t=e.closest(`.el-select`),n=e,r=t.querySelector(`.el-select__wrapper`)??t,i=()=>{let t=n.getAttribute(`aria-controls`);return t?e.ownerDocument.getElementById(t):null};return{root:t,input:n,wrapper:r,listbox:i,isOpen:()=>n.getAttribute(`aria-expanded`)===`true`&&ue(i()),items:()=>Array.from(i()?.querySelectorAll(`.el-select-dropdown__item`)??[]).filter(e=>ue(e)&&!e.classList.contains(`is-disabled`))}}async function _e(e){e.isOpen()&&(N(e.input,`Escape`),await F(()=>!e.isOpen(),300)||(e.wrapper.click(),await F(()=>!e.isOpen(),300)))}var ve={name:`element-plus-select`,detect:e=>he(e)&&!!e.closest(`.el-select`),async fill(e,t){let n=ge(e),r=fe(t);if(!r.length)return!0;if(n.isOpen()||n.wrapper.click(),!await F(()=>n.isOpen(),800))return!1;let i=n.listbox()?.getAttribute(`aria-multiselectable`)===`true`||n.root.querySelector(`.el-select__selection .el-tag`)!=null||r.length>1,a=!n.input.readOnly;if(i)for(let e of n.items().filter(e=>e.classList.contains(`is-selected`)))r.some(t=>de([e],t))||(e.click(),await m(30));let o=!0;for(let e of r){a&&(P(n.input,e),M(n.input,`input`),await m(120));let t=await F(()=>de(n.items(),e),500);if(!t)o=!1;else if(!(i&&t.classList.contains(`is-selected`))){if(t.click(),await m(40),!i)break;n.isOpen()||n.wrapper.click()}}return await _e(n),o},read(e){let t=e.closest(`.el-select`),n=Array.from(t.querySelectorAll(`.el-tag .el-select__tags-text`)).map(e=>e.textContent?.trim()??``);return n.length?n.join(` | `):t.querySelector(`.el-select__placeholder:not(.is-transparent)`)?.textContent?.trim()??``}};function I(){let e=Array.from(document.querySelectorAll(`.el-popper .el-cascader-panel`)).filter(ue);return e[e.length-1]??null}var ye=[ve,{name:`element-plus-cascader`,detect:e=>he(e)&&!!e.closest(`.el-cascader`),async fill(e,t){let n=e.closest(`.el-cascader`),r=t.split(/\s*[/>]\s*/).map(e=>e.trim()).filter(Boolean);if(!r.length)return!0;let i=I();if(!i&&(n.click(),i=await F(I,800),!i))return!1;for(let t=0;t<r.length;t++){let n=await F(()=>{let e=i.querySelectorAll(`.el-cascader-menu`)[t];return de(Array.from(e?.querySelectorAll(`.el-cascader-node:not(.is-disabled)`)??[]),r[t],e=>e.querySelector(`.el-cascader-node__label`)?.textContent??e.textContent??``)},600);if(!n)return N(e,`Escape`),document.body.click(),!1;n.click(),await m(60)}return I()&&(N(e,`Escape`),await m(50),I()&&document.body.click()),!0},read:e=>e.value},{name:`element-plus-date`,detect:e=>he(e)&&!!e.closest(`.el-date-editor`),async fill(e,t){let n=e;for(let e of pe(t))if(n.focus({preventScroll:!0}),P(n,e),M(n,`input`),M(n,`change`),await m(40),N(n,`Escape`),n.blur(),await m(40),n.value&&me(n.value,e))return!0;return!1},read:e=>e.value}],be=new Set([`1`,`true`,`evet`,`e`,`yes`,`y`,`on`,`x`,`secili`,`checked`]),xe=e=>be.has(i(e))||e.trim()===`✓`;function Se(e,t){let n=e.trim().match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(?:[ T](\d{1,2}):(\d{2}))?$/);if(!n)return e;let r=`${n[3]}-${n[2].padStart(2,`0`)}-${n[1].padStart(2,`0`)}`;return t===`datetime-local`?`${r}T${(n[4]??`00`).padStart(2,`0`)}:${n[5]??`00`}`:t===`month`?r.slice(0,7):r}var Ce={name:`native-text`,detect:e=>[`text`,`textarea`,`date`].includes(y(e)),fill(e,t){let n=e,r=(n.getAttribute(`type`)??`text`).toLowerCase(),i=y(e)===`date`?Se(t,r):t;return n.focus({preventScroll:!0}),P(n,i),M(n,`input`),M(n,`change`),n.blur(),y(e)!==`date`||n.value!==``||i===``},read:e=>e.value};function we(e,t){let n=Array.from(e.options),r=i(t);return n.find(e=>e.value===t)??n.find(e=>i(e.text)===r)??n.find(e=>r&&i(e.text).startsWith(r))??n.find(e=>a(e.text,t)>=.85)}var Te={name:`native-select`,detect:e=>e.tagName===`SELECT`,fill(e,t){let n=e,r=we(n,t);return r?(P(n,r.value),M(n,`input`),M(n,`change`),!0):!1},read(e){let t=e.selectedOptions[0];return t&&t.value!==``?t.text.trim():``}},Ee={name:`native-checkbox`,detect:e=>y(e)===`checkbox`,fill(e,t){let n=e;return n.checked!==xe(t)&&n.click(),!0},read:e=>e.checked?`true`:`false`},De={name:`native-radio`,detect:e=>y(e)===`radio`,fill(e,t){let n=O(e),r=i(t),o=n.find(e=>e.value===t)??n.find(e=>i(k(e))===r)??n.find(e=>i(e.value)===r)??n.find(e=>a(k(e),t)>=.8);return o?(o.checked||o.click(),!0):!1},read(e){let t=O(e).find(e=>e.checked);return t?k(t)||t.value:``}},Oe={name:`contenteditable`,detect:e=>y(e)===`contenteditable`,fill(e,t){let n=e;return n.focus({preventScroll:!0}),n.textContent=t,n.dispatchEvent(new InputEvent(`input`,{bubbles:!0,inputType:`insertText`,data:t})),n.blur(),!0},read:e=>e.textContent??``},ke=[...ye,Ee,De,Te,Oe,Ce],L=[];function Ae(e){let t=L.findIndex(t=>t.name===e.name);t>=0?L[t]=e:L.unshift(e)}function je(e){return L.find(t=>t.detect(e))??ke.find(t=>t.detect(e))}async function Me(e,t){let n=je(e);return n?await n.fill(e,t):!1}function R(e){return je(e)?.read?.(e)}var Ne={otofill:100,id:50,name:40,labelExact:35,css:30,labelFuzzy:25,placeholder:15,ariaLabel:15,type:5,index:5,mismatch:-10,wrongTag:-25,wrongKind:-40},Pe=30;function Fe(e,t){let n=e.match,r=Ne;if(n.otofill&&t.otofill)return n.otofill===t.otofill?r.otofill:0;let o=0;if(n.id&&t.id&&(o+=n.id===t.id?r.id:r.mismatch),n.name&&t.name&&(o+=n.name===t.name?r.name:r.mismatch),n.css)try{t.el.matches(n.css)&&(o+=r.css)}catch{}if(n.label&&t.label){let e=i(n.label),s=i(t.label);if(e===s)o+=r.labelExact;else{let t=a(e,s);t>=.6&&(o+=Math.round(r.labelFuzzy*t))}}return n.placeholder&&t.placeholder&&i(n.placeholder)===i(t.placeholder)&&(o+=r.placeholder),n.ariaLabel&&t.ariaLabel&&i(n.ariaLabel)===i(t.ariaLabel)&&(o+=r.ariaLabel),n.type&&t.type&&n.type===t.type&&(o+=r.type),n.index!=null&&n.index===t.index&&n.formKey===t.formKey&&(o+=r.index),n.tag&&t.tag&&n.tag!==t.tag&&(o+=r.wrongTag),e.kind&&e.kind!==t.kind&&(o+=r.wrongKind),o}function Ie(e,t,n=location.href){let r=e.filter(e=>ee(e.pages,n)),i=[];for(let e of r)for(let n of t){let t=Fe(e,n);t>=30&&i.push({def:e,fp:n,score:t})}i.sort((e,t)=>t.score-e.score);let a=new Set,o=new Set,s=[];for(let e of i)a.has(e.def.id)||o.has(e.fp)||(a.add(e.def.id),o.add(e.fp),s.push(e));return s.sort((e,t)=>(e.fp.index??0)-(t.fp.index??0)),{defs:r,matches:s,missing:r.filter(e=>!a.has(e.id)),free:t.filter(e=>!o.has(e))}}var Le=n({STATE_VERSION:()=>1,STORAGE_KEY:()=>Re,addRow:()=>Ze,clearAll:()=>Ge,createDataset:()=>Je,datasetKeys:()=>U,load:()=>V,migrate:()=>He,removeDataset:()=>Xe,removeField:()=>qe,removeRow:()=>Qe,save:()=>Ue,subscribe:()=>We,update:()=>H,upsertDataset:()=>Ye,upsertField:()=>Ke}),Re=`optona-otofill`,z=new Set,ze=null;function B(){return{v:1,fields:[],datasets:[],prefs:{cursor:{},closeAfterFill:!0}}}function Be(){try{return localStorage.getItem(Re)}catch{return ze}}function Ve(e){try{localStorage.setItem(Re,e)}catch{ze=e}}function He(e){let t=B();if(!e||typeof e!=`object`)return t;let n=e;return{v:1,fields:Array.isArray(n.fields)?n.fields:[],datasets:Array.isArray(n.datasets)?n.datasets:[],prefs:{...t.prefs,...n.prefs??{},cursor:{...n.prefs?.cursor??{}}}}}function V(){let e=Be();if(!e)return B();try{return He(JSON.parse(e))}catch{return B()}}function Ue(e){Ve(JSON.stringify(e)),z.forEach(t=>t(e))}function H(e){let t=V();return e(t),Ue(t),t}function We(e){return z.add(e),()=>z.delete(e)}typeof window<`u`&&window.addEventListener(`storage`,e=>{if(e.key===`optona-otofill`){let e=V();z.forEach(t=>t(e))}});function Ge(){Ue(B())}function Ke(e){let t={...e,id:e.id??s(),updatedAt:c()};return H(e=>{let n=e.fields.findIndex(e=>e.id===t.id);n>=0?e.fields[n]=t:e.fields.push(t)}),t}function qe(e){H(t=>{t.fields=t.fields.filter(t=>t.id!==e)})}function Je(e,t=[]){let n={id:s(),name:e,rows:t,updatedAt:c()};return H(e=>{e.datasets.push(n)}),n}function Ye(e){H(t=>{let n={...e,updatedAt:c()},r=t.datasets.findIndex(t=>t.id===e.id);r>=0?t.datasets[r]=n:t.datasets.push(n)})}function Xe(e){H(t=>{t.datasets=t.datasets.filter(t=>t.id!==e),delete t.prefs.cursor[e]})}function Ze(e,t){let n={...t,_id:t._id??s()};return H(t=>{let r=t.datasets.find(t=>t.id===e);r&&(r.rows.push(n),r.updatedAt=c())}),n}function Qe(e,t){H(n=>{let r=n.datasets.find(t=>t.id===e);r&&(r.rows=r.rows.filter(e=>e._id!==t))})}function U(e){let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>!e.startsWith(`_`)&&t.add(e))),[...t]}function W(e=V().fields,t=location.href){return Ie(e,j(document),t)}async function G(e,t={}){let n=t.retries??3,r=t.delay??300,i=new Set,a=new Set,o=W(),s=new Set;for(let c=0;c<=n;c++){a.clear();for(let n of o.matches){let r=n.def.key;if(i.has(n.def.id))continue;let o=e[r];if(o===void 0){s.add(r);continue}let c=!1;try{c=await Me(n.fp.el,o)}catch(e){console.warn(`[otofill]`,r,e)}c?(i.add(n.def.id),t.onFilled?.(n.fp.el)):a.add(r)}let l=o.missing.filter(t=>e[t.key]!==void 0&&!i.has(t.id));if(a.size===0&&l.length===0||c===n)break;await m(r),o=W()}let c=o,l=c.defs.filter(e=>i.has(e.id));return{filled:l.map(e=>e.key),notFound:c.missing.filter(t=>!i.has(t.id)&&e[t.key]!==void 0).map(e=>e.key),failed:[...a],noValue:[...s].filter(e=>!l.some(t=>t.key===e))}}function $e(e=W()){let t={};for(let n of e.matches){if(n.fp.type===`password`)continue;let e=R(n.fp.el);e!==void 0&&e!==``&&(t[n.def.key]=e)}return t}function et(e,t){let n=new Set(t);return e.map(e=>{let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>t.add(e))),{ds:e,overlap:[...n].filter(e=>t.has(e)).length}}).sort((e,t)=>t.overlap-e.overlap||e.ds.name.localeCompare(t.ds.name,`tr`))}function K(e,t=[]){return e._label?e._label:(t.length?t:Object.keys(e).filter(e=>!e.startsWith(`_`))).map(t=>e[t]).filter(e=>e&&e!==`true`&&e!==`false`).slice(0,2).join(` · `)||`(adsız satır)`}var q=`optona-otofill`,tt=1,nt=n({ImportError:()=>J,applyBundle:()=>at,csvToDataset:()=>ct,datasetToCsv:()=>ot,download:()=>lt,exportCsv:()=>dt,exportJson:()=>ut,importFile:()=>pt,importText:()=>ft,makeBundle:()=>rt,parseCsv:()=>st,summaryText:()=>mt,validateBundle:()=>it});function rt(e=V(),t={fields:!0,datasets:!0}){let n={format:q,version:1,exportedAt:c()};return t.fields&&(n.fields=e.fields),t.datasets&&(n.datasets=Array.isArray(t.datasets)?e.datasets.filter(e=>t.datasets.includes(e.id)):e.datasets),n}var J=class extends Error{};function Y(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function it(e){if(!Y(e))throw new J(`Dosya bir JSON nesnesi değil.`);if(e.format!==`optona-otofill`)throw new J(`Bu bir Otofill dosyası değil (format: "${String(e.format)}").`);let t=Number(e.version);if(!t||t>1)throw new J(`Dosya sürümü (${String(e.version)}) bu kütüphaneden yeni. Kütüphaneyi güncelleyin.`);let n={format:q,version:1,exportedAt:String(e.exportedAt??c())};if(e.fields!==void 0){if(!Array.isArray(e.fields))throw new J(`"fields" bir dizi olmalı.`);n.fields=e.fields.map((e,t)=>{if(!Y(e)||typeof e.key!=`string`||!e.key.trim())throw new J(`fields[${t}]: "key" eksik.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),key:e.key.trim(),title:typeof e.title==`string`?e.title:void 0,pages:Array.isArray(e.pages)?e.pages.map(String):[],kind:typeof e.kind==`string`?e.kind:void 0,match:Y(e.match)?e.match:{},updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0}})}if(e.datasets!==void 0){if(!Array.isArray(e.datasets))throw new J(`"datasets" bir dizi olmalı.`);n.datasets=e.datasets.map((e,t)=>{if(!Y(e)||typeof e.name!=`string`)throw new J(`datasets[${t}]: "name" eksik.`);if(!Array.isArray(e.rows))throw new J(`datasets[${t}]: "rows" bir dizi olmalı.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),name:e.name,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0,rows:e.rows.map((e,n)=>{if(!Y(e))throw new J(`datasets[${t}].rows[${n}] bir nesne değil.`);let r={_id:typeof e._id==`string`&&e._id?e._id:s()};for(let[t,n]of Object.entries(e))t!==`_id`&&n!=null&&(r[t]=String(n));return r})}})}if(!n.fields&&!n.datasets)throw new J(`Dosyada ne alan tanımı ne de veri seti var.`);return n}function at(e,t,n){let r={fieldsAdded:0,fieldsUpdated:0,datasetsAdded:0,datasetsUpdated:0,rows:0},i=t.fields??[],a=t.datasets??[];if(r.rows=a.reduce((e,t)=>e+t.rows.length,0),n===`copy`)return i.forEach(t=>e.fields.push({...t,id:s()})),a.forEach(t=>e.datasets.push({...t,id:s(),rows:t.rows.map(e=>({...e,_id:s()}))})),r.fieldsAdded=i.length,r.datasetsAdded=a.length,r;if(n===`replace`)return t.fields&&(e.fields=[...i],r.fieldsAdded=i.length),t.datasets&&(e.datasets=[...a],r.datasetsAdded=a.length),r;for(let t of i){let n=e.fields.findIndex(e=>e.id===t.id||e.key===t.key&&e.pages.join(`|`)===t.pages.join(`|`));n>=0?(e.fields[n]={...t,id:e.fields[n].id},r.fieldsUpdated++):(e.fields.push(t),r.fieldsAdded++)}for(let t of a){let n=e.datasets.find(e=>e.id===t.id)??e.datasets.find(e=>e.name===t.name);if(!n)e.datasets.push(t),r.datasetsAdded++;else{for(let e of t.rows){let t=n.rows.findIndex(t=>t._id===e._id);t>=0?n.rows[t]=e:n.rows.push(e)}n.updatedAt=c(),r.datasetsUpdated++}}return r}function ot(e,t=U(e)){let n=e=>{let t=e??``;return/[;"\r\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t},r=[`_label`,...t],i=[r.map(n).join(`;`)];for(let t of e.rows)i.push(r.map(e=>n(t[e])).join(`;`));return``+i.join(`\r
|
|
2
|
+
`)}function st(e){e=e.replace(/^/,``);let t=e.split(/\r?\n/,1)[0]??``,n=e=>t.split(e).length-1,r=[`;`,`,`,` `].sort((e,t)=>n(t)-n(e))[0],i=[],a=[],o=``,s=!1;for(let t=0;t<e.length;t++){let n=e[t];s?n===`"`&&e[t+1]===`"`?(o+=`"`,t++):n===`"`?s=!1:o+=n:n===`"`?s=!0:n===r?(a.push(o),o=``):n===`
|
|
3
|
+
`||n===`\r`?(n===`\r`&&e[t+1]===`
|
|
4
|
+
`&&t++,a.push(o),i.push(a),a=[],o=``):o+=n}return(o!==``||a.length)&&(a.push(o),i.push(a)),i.filter(e=>e.some(e=>e.trim()!==``))}function ct(e,t){let n=st(e);if(n.length<1)throw new J(`CSV boş.`);let r=n[0].map(e=>e.trim());if(r.filter(e=>e&&!e.startsWith(`_`)).length===0)throw new J(`CSV başlık satırında anahtar yok.`);return{id:s(),name:t,updatedAt:c(),rows:n.slice(1).map(e=>{let t={_id:s()};return r.forEach((n,r)=>{if(!n)return;let i=e[r]??``;n===`_label`||n.toLocaleLowerCase(`tr`)===`etiket`?t._label=i:n===`_id`?t._id=i||t._id:i!==``&&(t[n]=i)}),t})}}function lt(e,t,n=`application/json`){let r=new Blob([t],{type:`${n};charset=utf-8`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=e,document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(i.href),i.remove()},0)}function ut(e,t){let n=rt(V(),e),r=new Date().toISOString().slice(0,10);lt(t??`otofill-${r}.json`,JSON.stringify(n,null,2))}function dt(e){let t=V().datasets.find(t=>t.id===e);t&<(`${t.name.replace(/[\\/:*?"<>|]+/g,`_`)}.csv`,ot(t),`text/csv`)}function ft(e,t,n=`veri.json`){let r,i=e.replace(/^/,``).trimStart();if(/\.csv$/i.test(n)||!(i.startsWith(`{`)||i.startsWith(`[`))){let t=n.replace(/\.[^.]+$/,``)||`CSV verisi`;r={format:q,version:1,exportedAt:c(),datasets:[ct(e,t)]}}else{let e;try{e=JSON.parse(i)}catch(e){throw new J(`JSON okunamadı: `+e.message)}r=it(e)}let a=V(),o=at(a,r,t);return Ue(a),o}async function pt(e,t){return ft(await e.text(),t,e.name)}function mt(e){let t=[];return e.fieldsAdded&&t.push(`${e.fieldsAdded} alan eklendi`),e.fieldsUpdated&&t.push(`${e.fieldsUpdated} alan güncellendi`),e.datasetsAdded&&t.push(`${e.datasetsAdded} veri seti eklendi`),e.datasetsUpdated&&t.push(`${e.datasetsUpdated} veri seti güncellendi`),e.rows&&t.push(`${e.rows} satır`),t.join(`, `)||`Değişiklik yok`}function X(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&(e.startsWith(`on`)&&typeof n==`function`?r.addEventListener(e.slice(2).toLowerCase(),n):e===`class`?r.className=String(n):e===`value`?r.value=String(n):e===`checked`?r.checked=!!n:e===`style`&&typeof n==`object`?Object.assign(r.style,n):r.setAttribute(e,n===!0?``:String(n)));return ht(r,n),r}function ht(e,t){for(let n of t)n!=null&&n!==!1&&(Array.isArray(n)?ht(e,n):e.appendChild(typeof n==`object`?n:document.createTextNode(String(n))))}function gt(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()),n=t[t.length-1],r=/^[a-z]$/.test(n)?`Key${n.toUpperCase()}`:/^\d$/.test(n)?`Digit${n}`:n[0].toUpperCase()+n.slice(1);return{ctrl:t.includes(`ctrl`),shift:t.includes(`shift`),alt:t.includes(`alt`),meta:t.includes(`meta`)||t.includes(`cmd`),code:r}}function _t(e,t){return e.code===t.code&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.altKey===t.alt&&e.metaKey===t.meta}var vt=`
|
|
5
|
+
:host { all: initial; }
|
|
6
|
+
* { box-sizing: border-box; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
7
|
+
.panel {
|
|
8
|
+
position: fixed; top: 16px; right: 16px; width: 380px; max-height: calc(100vh - 32px);
|
|
9
|
+
display: flex; flex-direction: column; background: #fff; color: #1f2937; font-size: 13px; line-height: 1.4;
|
|
10
|
+
border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.22); z-index: 2147483646; overflow: hidden;
|
|
11
|
+
resize: both; min-width: 300px; min-height: 160px; max-width: calc(100vw - 16px);
|
|
12
|
+
}
|
|
13
|
+
.ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
|
|
14
|
+
.head button .ico { vertical-align: middle; }
|
|
15
|
+
.mini {
|
|
16
|
+
position: fixed; z-index: 2147483646; display: flex; align-items: center; gap: 2px; padding: 3px;
|
|
17
|
+
background: #111827; border-radius: 20px; box-shadow: 0 6px 20px rgba(0,0,0,.3); cursor: move; user-select: none;
|
|
18
|
+
}
|
|
19
|
+
.mini button { border: 0; cursor: pointer; color: #fff; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
|
|
20
|
+
.mini .mfill { background: #2563eb; border-radius: 16px; padding: 5px 11px; font-weight: 600; }
|
|
21
|
+
.mini .mfill:hover { background: #1d4ed8; }
|
|
22
|
+
.mini .mfill.off { background: #4b5563; }
|
|
23
|
+
.mini .mico { background: transparent; color: #d1d5db; width: 26px; height: 26px; border-radius: 13px; justify-content: center; font-size: 16px; }
|
|
24
|
+
.mini .mico:hover { background: #374151; color: #fff; }
|
|
25
|
+
.head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #111827; color: #fff; cursor: move; user-select: none; }
|
|
26
|
+
.head b { font-size: 13px; letter-spacing: .2px; }
|
|
27
|
+
.head .sub { color: #9ca3af; font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
28
|
+
.head button { background: transparent; border: 0; color: #d1d5db; font-size: 16px; cursor: pointer; padding: 0 4px; }
|
|
29
|
+
.tabs { display: flex; border-bottom: 1px solid #e5e7eb; background: #f9fafb; }
|
|
30
|
+
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 4px; cursor: pointer; font-size: 12px; color: #4b5563; border-bottom: 2px solid transparent; }
|
|
31
|
+
.tabs button.on { color: #111827; border-bottom-color: #2563eb; font-weight: 600; }
|
|
32
|
+
.body { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
|
|
33
|
+
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
|
|
34
|
+
.muted { color: #6b7280; font-size: 12px; }
|
|
35
|
+
.sec { font-weight: 600; font-size: 12px; color: #374151; margin-top: 2px; }
|
|
36
|
+
button.btn { border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; color: #1f2937; }
|
|
37
|
+
button.btn:hover { background: #f3f4f6; }
|
|
38
|
+
button.pri { background: #2563eb; border-color: #2563eb; color: #fff; }
|
|
39
|
+
button.pri:hover { background: #1d4ed8; }
|
|
40
|
+
button.dng { color: #b91c1c; border-color: #fca5a5; }
|
|
41
|
+
button.sm { padding: 2px 6px; font-size: 11px; }
|
|
42
|
+
button:disabled { opacity: .5; cursor: default; }
|
|
43
|
+
input[type=text], select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 5px 7px; font-size: 12px; color: #111827; background: #fff; min-width: 0; }
|
|
44
|
+
input[type=text]:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }
|
|
45
|
+
textarea { width: 100%; min-height: 70px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
|
|
46
|
+
.grow { flex: 1; }
|
|
47
|
+
.list { display: flex; flex-direction: column; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
|
|
48
|
+
.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid #f3f4f6; }
|
|
49
|
+
.item:first-child { border-top: 0; }
|
|
50
|
+
.item.click { cursor: pointer; }
|
|
51
|
+
.item.click:hover, .item.cur { background: #eff6ff; }
|
|
52
|
+
.num { min-width: 18px; height: 18px; border-radius: 4px; background: #e5e7eb; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; color: #374151; }
|
|
53
|
+
.key { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #1e40af; }
|
|
54
|
+
.ok { color: #15803d; } .bad { color: #b91c1c; } .warn { color: #b45309; }
|
|
55
|
+
.toast { padding: 7px 9px; border-radius: 6px; font-size: 12px; }
|
|
56
|
+
.toast.ok { background: #dcfce7; color: #14532d; } .toast.err { background: #fee2e2; color: #7f1d1d; }
|
|
57
|
+
.drop { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 14px; text-align: center; color: #64748b; cursor: pointer; }
|
|
58
|
+
.drop.over { border-color: #2563eb; background: #eff6ff; }
|
|
59
|
+
.empty { padding: 14px; text-align: center; color: #6b7280; }
|
|
60
|
+
table { border-collapse: collapse; width: 100%; font-size: 11px; }
|
|
61
|
+
th, td { border-bottom: 1px solid #f3f4f6; padding: 3px 4px; text-align: left; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
62
|
+
th { color: #6b7280; font-weight: 600; }
|
|
63
|
+
label.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
|
|
64
|
+
.layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483645; }
|
|
65
|
+
.hl { position: fixed; border: 2px solid #2563eb; background: rgba(37,99,235,.08); border-radius: 4px; transition: opacity .4s; }
|
|
66
|
+
.hl.green { border-color: #16a34a; background: rgba(22,163,74,.12); }
|
|
67
|
+
.badge { position: fixed; transform: translateY(-100%); font: 600 10px/1.6 ui-monospace, Consolas, monospace; padding: 0 5px; border-radius: 4px 4px 4px 0; background: #16a34a; color: #fff; white-space: nowrap; }
|
|
68
|
+
.badge.free { background: #6b7280; }
|
|
69
|
+
.teachbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; pointer-events: auto; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
|
|
70
|
+
.teachbar button { background: #374151; color: #fff; border: 0; border-radius: 12px; padding: 3px 10px; cursor: pointer; }
|
|
71
|
+
.pop { position: fixed; width: 300px; background: #fff; border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 10px; pointer-events: auto; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: #1f2937; }
|
|
72
|
+
.pop .lbl { font-size: 11px; color: #6b7280; }
|
|
73
|
+
.pop input[type=text], .pop select { width: 100%; }
|
|
74
|
+
.pop .row select { width: auto; flex: 1; min-width: 0; }
|
|
75
|
+
.pop .sep { border-top: 1px solid #e5e7eb; margin: 2px 0; }
|
|
76
|
+
.pop .lbl.warn { color: #b45309; }
|
|
77
|
+
`,yt={text:`metin`,textarea:`çok satır`,select:`seçim`,checkbox:`onay kutusu`,radio:`seçenek grubu`,date:`tarih`,contenteditable:`zengin metin`,other:`diğer`},bt=`optona-otofill:ui`;function xt(){try{return JSON.parse(localStorage.getItem(bt)||`{}`)}catch{return{}}}function Z(e){try{localStorage.setItem(bt,JSON.stringify(e))}catch{}}var St=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,Ct=`<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor" stroke="none"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`,wt=e=>{let t=document.createElement(`span`);return t.className=`ico`,t.innerHTML=e,t},Tt=class{constructor(e){this.opts=e,this.visible=!1,this.view=`fill`,this.result=null,this.lastFill=null,this.toastMsg=``,this.toastKind=`ok`,this.toastTimer=0,this.pattern=``,this.importMode=`merge`,this.inspecting=!1,this.teaching=!1,this.teachPop=null,this.freeSel=new Map,this.teachTarget={dsId:`__new`,rowId:`__new`},this.ui=xt(),this.minimized=!1,this.miniMsg=``,this.raf=0,this.onKey=e=>{if(_t(e,this.opts.hotkey)){e.preventDefault(),e.stopPropagation(),this.toggle();return}if(e.key===`Escape`){this.teachPop?(this.closeTeachPop(),e.preventDefault()):this.teaching&&(this.stopTeach(),e.preventDefault());return}if(!this.visible||this.view!==`fill`||this.teaching)return;let t=this.root.activeElement??document.activeElement;if(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)))return;let n=this.currentDataset();if(n){if(/^Digit[1-9]$/.test(e.code)&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let t=Number(e.code.slice(5))-1;n.rows[t]&&(e.preventDefault(),this.fillWith(n,t))}else e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),this.fillNext(n))}},this.startDrag=e=>{if(e.target.tagName===`BUTTON`)return;let t=this.box.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=e=>{this.ui.left=Math.max(0,Math.min(window.innerWidth-60,e.clientX-n)),this.ui.top=Math.max(0,Math.min(window.innerHeight-40,e.clientY-r)),Object.assign(this.box.style,{left:`${this.ui.left}px`,top:`${this.ui.top}px`,right:`auto`})},a=()=>{window.removeEventListener(`mousemove`,i,!0),window.removeEventListener(`mouseup`,a,!0),Z(this.ui)};window.addEventListener(`mousemove`,i,!0),window.addEventListener(`mouseup`,a,!0),e.preventDefault()},this.startMiniDrag=e=>{if(e.target.closest(`button`))return;let t=this.mini.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=e=>{this.ui.miniLeft=Math.max(0,Math.min(window.innerWidth-140,e.clientX-n)),this.ui.miniTop=Math.max(0,Math.min(window.innerHeight-40,e.clientY-r)),Object.assign(this.mini.style,{left:`${this.ui.miniLeft}px`,top:`${this.ui.miniTop}px`})},a=()=>{window.removeEventListener(`mousemove`,i,!0),window.removeEventListener(`mouseup`,a,!0),Z(this.ui)};window.addEventListener(`mousemove`,i,!0),window.addEventListener(`mouseup`,a,!0),e.preventDefault()},this.hoverEl=null,this.onViewport=()=>{(this.inspecting||this.hoverEl||this.teaching)&&(cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>this.drawLayer()))},this.onTeachMove=e=>{if(this.fromPanel(e)||this.teachPop)return;let t=x(e.composedPath()[0]);t!==this.hoverEl&&this.hover(t)},this.onTeachPointer=e=>{if(this.fromPanel(e)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.type!==`click`))return;let t=x(e.composedPath()[0]);t?this.openTeachPop(t):this.teachPop&&this.closeTeachPop()}}mount(){if(this.host)return;if(this.host=document.createElement(ne),this.host.setAttribute(`data-otofill-host`,``),this.root=this.host.attachShadow({mode:`open`}),this.root.appendChild(X(`style`,{},vt)),this.layer=X(`div`,{class:`layer`}),this.box=X(`div`,{class:`panel`,style:{display:`none`}}),this.mini=X(`div`,{class:`mini`,style:{display:`none`},onMousedown:this.startMiniDrag}),this.root.append(this.layer,this.box,this.mini),document.documentElement.appendChild(this.host),typeof ResizeObserver<`u`){let e=0;new ResizeObserver(()=>{this.visible&&this.box.style.width&&(clearTimeout(e),e=window.setTimeout(()=>{this.ui.w=this.box.style.width,this.ui.h=this.box.style.height,Z(this.ui)},300))}).observe(this.box)}let e=()=>this.minimized&&this.renderMini();window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),this.ui.min&&setTimeout(()=>this.showMini(),300);for(let e of[`keydown`,`keyup`,`keypress`])this.host.addEventListener(e,e=>e.stopPropagation());window.addEventListener(`keydown`,this.onKey,!0),window.addEventListener(`scroll`,this.onViewport,!0),window.addEventListener(`resize`,this.onViewport),We(()=>this.visible?this.refresh():this.minimized?this.renderMini():void 0)}show(){this.mount(),this.visible=!0,this.minimized=!1,this.mini.style.display=`none`,this.ui.min&&(this.ui.min=!1,Z(this.ui)),this.pattern||=u(),this.box.style.display=`flex`,this.applyBox(),this.refresh()}hide(){this.visible=!1,this.minimized=!1,this.box.style.display=`none`,this.mini&&(this.mini.style.display=`none`),this.ui.min&&(this.ui.min=!1,Z(this.ui)),this.stopTeach(),this.inspecting=!1,this.drawLayer()}toggle(){this.visible?this.hide():this.show()}minimize(){let e=this.box.getBoundingClientRect();this.ui.miniLeft=Math.round(e.right-132),this.ui.miniTop=Math.round(e.top),this.stopTeach(),this.inspecting=!1,this.visible=!1,this.box.style.display=`none`,this.showMini(),this.drawLayer()}showMini(){this.mount(),this.minimized=!0,this.ui.min=!0,Z(this.ui),this.mini.style.display=`flex`,this.renderMini()}applyBox(){let e=this.ui;if(e.w&&(this.box.style.width=e.w),e.h&&(this.box.style.height=e.h),e.left!=null&&e.top!=null){let t=Math.max(0,Math.min(window.innerWidth-80,e.left)),n=Math.max(0,Math.min(window.innerHeight-40,e.top));Object.assign(this.box.style,{left:`${t}px`,top:`${n}px`,right:`auto`})}}quickTarget(){this.result=W();let e=this.currentDataset();if(!e||!e.rows.length)return null;let t=V().prefs.cursor[e.id];return{ds:e,i:t==null?0:(t-1+e.rows.length)%e.rows.length}}renderMini(){if(!this.mini)return;let e=this.quickTarget(),t=Math.max(0,Math.min(window.innerWidth-140,this.ui.miniLeft??window.innerWidth-148)),n=Math.max(0,Math.min(window.innerHeight-40,this.ui.miniTop??16));Object.assign(this.mini.style,{left:`${t}px`,top:`${n}px`});let r=X(`button`,{class:`mfill`+(e?``:` off`),title:e?`Doldur: ${e.ds.name} › ${K(e.ds.rows[e.i])}`:`Bu sayfa için uygun veri yok: paneli açar`,onClick:()=>void this.quickFill()},wt(Ct),this.miniMsg||`Doldur`);this.mini.replaceChildren(r,X(`button`,{class:`mico`,title:`Paneli aç (Ctrl+Q)`,onClick:()=>this.show()},wt(St)),X(`button`,{class:`mico`,title:`Kapat`,onClick:()=>this.hide()},`×`))}async quickFill(){let e=this.quickTarget();if(!e){this.show();return}let t=e.ds.rows[e.i];H(t=>{t.prefs.lastDatasetId=e.ds.id,t.prefs.cursor[e.ds.id]=(e.i+1)%e.ds.rows.length});let n=await G(t,{onFilled:e=>this.flash(e)});this.lastFill=n;let r=n.notFound.length+n.failed.length;r?(this.view=`fill`,this.show(),this.toast(`"${K(t)}": ${n.filled.length} alan dolduruldu, ${r} sorunlu`,`err`)):(this.miniMsg=`✓ ${n.filled.length}`,this.renderMini(),setTimeout(()=>{this.miniMsg=``,this.minimized&&this.renderMini()},1500))}isOpen(){return this.visible}refresh(){this.result=W(),this.render(),this.drawLayer()}toast(e,t=`ok`){this.toastMsg=e,this.toastKind=t,clearTimeout(this.toastTimer),this.toastTimer=window.setTimeout(()=>{this.toastMsg=``,this.visible&&this.render()},5e3),this.visible&&this.render()}currentDataset(){let e=V(),t=this.pageKeys(),n=et(e.datasets,t).filter(e=>e.overlap>0),r=this.dsId??e.prefs.lastDatasetId;return n.find(e=>e.ds.id===r)?.ds??n[0]?.ds}pageKeys(){return[...new Set((this.result?.matches??[]).map(e=>e.def.key))]}async fillWith(e,t){let n=e.rows[t];if(!n)return;H(n=>{n.prefs.lastDatasetId=e.id,n.prefs.cursor[e.id]=(t+1)%e.rows.length});let r=await G(n,{onFilled:e=>this.flash(e)});this.lastFill=r;let i=r.notFound.length+r.failed.length;V().prefs.closeAfterFill&&i===0?this.hide():this.toast(`"${K(n)}": ${r.filled.length} alan dolduruldu`+(i?`, ${i} sorunlu`:``),i?`err`:`ok`)}fillNext(e){let t=V().prefs.cursor[e.id]??0;return this.fillWith(e,t<e.rows.length?t:0)}fillRandom(e){return this.fillWith(e,Math.floor(Math.random()*e.rows.length))}render(){let e=this.result,t=X(`div`,{class:`head`,onMousedown:this.startDrag},X(`b`,{},`Otofill`),X(`span`,{class:`sub`},`${e.matches.length}/${e.defs.length} alan · ${location.host}`),X(`button`,{title:`Yeniden tara`,onClick:()=>this.refresh()},`⟳`),X(`button`,{title:`Küçült: tek düğmeye çevirir`,onClick:()=>this.minimize()},wt(St)),X(`button`,{title:`Kapat (Ctrl+Q)`,onClick:()=>this.hide()},`×`)),n=(e,t)=>X(`button`,{class:this.view===e?`on`:``,onClick:()=>{this.view=e,this.render(),this.drawLayer()}},t),r=X(`div`,{class:`tabs`},n(`fill`,`Doldur`),n(`fields`,`Alanlar`),n(`data`,`Veri`),n(`io`,`Aktar`)),i=X(`div`,{class:`body`});this.toastMsg&&i.appendChild(X(`div`,{class:`toast ${this.toastKind}`},this.toastMsg)),this.view===`fill`?this.renderFill(i):this.view===`fields`?this.renderFields(i):this.view===`data`?this.renderData(i):this.renderIo(i);let a=this.box.querySelector(`.body`)?.scrollTop??0;this.box.replaceChildren(t,r,i),i.scrollTop=a}renderFill(e){let t=this.result,n=V();if(t.defs.length===0){e.append(X(`div`,{class:`empty`},`Bu sayfa için tanımlı alan yok.`,X(`br`),`Önce alanları tanıtın ya da tanımları içe aktarın.`),X(`div`,{class:`row`},X(`button`,{class:`btn pri grow`,onClick:()=>{this.view=`fields`,this.startTeach()}},`Tıklayarak alan tanıt`),X(`button`,{class:`btn grow`,onClick:()=>{this.view=`io`,this.render()}},`İçe aktar`)));return}let r=et(n.datasets,this.pageKeys()).filter(e=>e.overlap>0);if(r.length===0){e.append(X(`div`,{class:`empty`},`${t.matches.length} alan tanındı ama bu alanlara uyan veri seti yok.`,X(`br`),`Veri sekmesinden sayfadaki değerleri kaydedin ya da veri içe aktarın.`),X(`div`,{class:`row`},X(`button`,{class:`btn grow`,onClick:()=>{this.view=`data`,this.render()}},`Veri sekmesi`)));return}let i=this.currentDataset(),a=this.pageKeys(),o=n.prefs.cursor[i.id]??0;e.append(X(`div`,{class:`row`},X(`select`,{class:`grow`,onChange:e=>{this.dsId=e.target.value,this.render()}},r.map(e=>X(`option`,{value:e.ds.id,selected:e.ds.id===i.id||void 0},`${e.ds.name} (${e.overlap} alan · ${e.ds.rows.length} satır)`)))),i.rows.length===0?X(`div`,{class:`empty`},`Bu veri setinde satır yok.`):X(`div`,{class:`list`},i.rows.map((e,t)=>X(`div`,{class:`item click`+(t===o?` cur`:``),title:`Bu satırla doldur`,onClick:()=>this.fillWith(i,t)},X(`span`,{class:`num`},t<9?String(t+1):`·`),X(`span`,{class:`grow`},K(e,a)),t===o?X(`span`,{class:`muted`},`sıradaki`):null))),X(`div`,{class:`row`},X(`button`,{class:`btn pri grow`,disabled:!i.rows.length||void 0,onClick:()=>this.fillNext(i)},`Sıradaki satır (Enter)`),X(`button`,{class:`btn`,disabled:!i.rows.length||void 0,onClick:()=>this.fillRandom(i)},`Rastgele`)),X(`label`,{class:`opt muted`},X(`input`,{type:`checkbox`,checked:n.prefs.closeAfterFill,onChange:e=>H(t=>{t.prefs.closeAfterFill=e.target.checked})}),`Sorunsuz doldurunca paneli kapat · 1-9: satır seç`));let s=this.lastFill;if(s){let t=(e,t,n)=>n.length?X(`div`,{class:e},`${t}: `,X(`span`,{class:`key`},n.join(`, `))):null;e.append(X(`div`,{},t(`ok`,`Dolduruldu`,s.filled),t(`bad`,`Sayfada bulunamadı`,s.notFound),t(`bad`,`Yazılamadı`,s.failed),t(`muted`,`Satırda değeri yok`,s.noValue)))}t.missing.length&&e.append(X(`div`,{class:`muted`},`Tanımlı ama bulunamayan: ${t.missing.map(e=>e.key).join(`, `)}`))}renderFields(e){let t=this.result,n=te(),r=u();e.append(X(`div`,{class:`row`},X(`button`,{class:`btn pri grow`,onClick:()=>this.startTeach()},`Tıklayarak tanıt`),X(`button`,{class:`btn`+(this.inspecting?` pri`:``),onClick:()=>{this.inspecting=!this.inspecting,this.render(),this.drawLayer()}},this.inspecting?`Göstermeyi kapat`:`Sayfada göster`)),X(`div`,{class:`muted`},`Yeni tanımların geçerli olacağı adres (* joker):`),X(`div`,{class:`row`},X(`input`,{type:`text`,class:`grow`,value:this.pattern,onChange:e=>{this.pattern=e.target.value.trim()}}),X(`button`,{class:`btn sm`,title:r,onClick:()=>{this.pattern=r,this.render()}},`Bu sayfa`),X(`button`,{class:`btn sm`,title:n,onClick:()=>{this.pattern=n,this.render()}},`Tüm site`)),X(`div`,{class:`sec`},`Bu sayfadaki tanımlar (${t.defs.length})`)),t.defs.length===0?e.append(X(`div`,{class:`muted`},`Henüz yok.`)):e.append(X(`div`,{class:`list`},t.defs.map(e=>{let n=t.matches.find(t=>t.def.id===e.id);return X(`div`,{class:`item`,onMouseenter:()=>n&&this.hover(n.fp.el),onMouseleave:()=>this.hover(null)},X(`span`,{class:n?`ok`:`bad`,title:n?`puan ${n.score}`:`sayfada bulunamadı`},n?`●`:`○`),X(`span`,{class:`grow`},X(`span`,{class:`key`},e.key),e.title?X(`span`,{class:`muted`},` · ${e.title}`):null),X(`span`,{class:`muted`},n?String(n.score):`—`),X(`button`,{class:`btn sm dng`,title:`Tanımı sil`,onClick:()=>{confirm(`"${e.key}" tanımı silinsin mi?`)&&qe(e.id)}},`Sil`))})));let i=new Set(t.defs.map(e=>e.key)),a=new Set;for(let e of t.free)if(!this.freeSel.has(e)){let t=o(e.label||e.name||e.placeholder||e.id)||`alan_${(e.index??0)+1}`,n=2,r=t;for(;i.has(t)||a.has(t);)t=`${r}_${n++}`;a.add(t),this.freeSel.set(e,{on:!1,key:t})}e.append(X(`div`,{class:`sec`},`Tanımsız alanlar (${t.free.length})`)),t.free.length===0?e.append(X(`div`,{class:`muted`},`Sayfadaki tüm görünür alanlar tanımlı.`)):e.append(X(`div`,{class:`list`},t.free.map(e=>{let t=this.freeSel.get(e);return X(`div`,{class:`item`,onMouseenter:()=>this.hover(e.el),onMouseleave:()=>this.hover(null)},X(`input`,{type:`checkbox`,checked:t.on,onChange:e=>{t.on=e.target.checked}}),X(`div`,{class:`grow`,style:{display:`flex`,flexDirection:`column`,gap:`2px`,minWidth:`0`}},X(`input`,{type:`text`,value:t.key,onInput:e=>{t.key=e.target.value.trim(),t.on=!0,e.target.parentElement.previousSibling.checked=!0}}),X(`span`,{class:`muted`},`${e.label||e.placeholder||e.name||`(etiketsiz)`} · ${yt[e.kind]}`)))})),X(`div`,{class:`row`},X(`button`,{class:`btn`,onClick:()=>{let e=[...this.freeSel.values()].every(e=>e.on);t.free.forEach(t=>this.freeSel.get(t).on=!e),this.render()}},`Tümünü seç / bırak`),X(`button`,{class:`btn pri grow`,onClick:()=>this.saveFree()},`Seçilenleri kaydet`)))}saveFree(){let e=this.result.free.filter(e=>this.freeSel.get(e)?.on&&this.freeSel.get(e).key);if(!e.length)return this.toast(`Kaydedilecek alan seçilmedi.`,`err`);H(t=>{for(let n of e)t.fields.push(this.defFrom(n,this.freeSel.get(n).key))}),e.forEach(e=>this.freeSel.delete(e)),this.toast(`${e.length} alan tanımlandı.`)}defFrom(e,t,n,r,i){return{id:i??s(),key:t,title:n??e.label,pages:r??[this.pattern||u()],kind:e.kind,match:le(e),updatedAt:c()}}renderData(e){let t=this.result,n=V(),r=this.pageKeys(),i=n.datasets.find(e=>e.id===(this.openDsId??n.prefs.lastDatasetId))?.id??n.datasets[0]?.id??`__new`,a=``,o=``;e.append(X(`div`,{class:`sec`},`Sayfadaki değerleri satır olarak kaydet`),X(`div`,{class:`muted`},r.length?`Tanınan ${r.length} alanın o anki değerleri okunur. Formu elle doldurup buradan kaydedebilirsiniz.`:`Önce bu sayfadaki alanları tanıtın.`),X(`div`,{class:`row`},X(`select`,{class:`grow`,onChange:e=>{i=e.target.value,s.style.display=i===`__new`?``:`none`}},n.datasets.map(e=>X(`option`,{value:e.id,selected:e.id===i||void 0},e.name)),X(`option`,{value:`__new`,selected:i===`__new`||void 0},`+ Yeni veri seti`))));let s=X(`input`,{type:`text`,placeholder:`Yeni veri setinin adı`,style:{display:i===`__new`?``:`none`},onInput:e=>{a=e.target.value}});e.append(s,X(`div`,{class:`row`},X(`input`,{type:`text`,class:`grow`,placeholder:`Satır adı (ör. "Bireysel - İstanbul")`,onInput:e=>{o=e.target.value}}),X(`button`,{class:`btn pri`,disabled:!r.length||void 0,onClick:()=>{let e=$e(t),n=i;i===`__new`&&(n=Je(a.trim()||`Veri ${new Date().toLocaleDateString(`tr-TR`)}`).id),Ze(n,{...e,...o.trim()?{_label:o.trim()}:{}}),this.openDsId=n,this.toast(`${Object.keys(e).length} değer satır olarak kaydedildi.`)}},`Kaydet`)),X(`div`,{class:`sec`},`Veri setleri (${n.datasets.length})`)),n.datasets.length?e.append(X(`div`,{class:`list`},n.datasets.map(e=>{let t=this.openDsId===e.id,n=(r.length?r.filter(t=>U(e).includes(t)):U(e)).slice(0,5);return X(`div`,{},X(`div`,{class:`item click`,onClick:()=>{this.openDsId=t?void 0:e.id,this.render()}},X(`span`,{},t?`▾`:`▸`),X(`span`,{class:`grow`},e.name),X(`span`,{class:`muted`},`${e.rows.length} satır`),X(`button`,{class:`btn sm`,title:`CSV indir`,onClick:t=>{t.stopPropagation(),dt(e.id)}},`CSV`),X(`button`,{class:`btn sm dng`,onClick:t=>{t.stopPropagation(),confirm(`"${e.name}" veri seti silinsin mi?`)&&Xe(e.id)}},`Sil`)),t?X(`div`,{style:{padding:`0 8px 8px`,overflowX:`auto`}},X(`table`,{},X(`tr`,{},X(`th`,{},`Satır`),n.map(e=>X(`th`,{title:e},e)),X(`th`,{})),e.rows.map(t=>X(`tr`,{},X(`td`,{title:K(t)},K(t)),n.map(e=>X(`td`,{title:t[e]??``},t[e]??``)),X(`td`,{},X(`button`,{class:`btn sm dng`,title:`Satırı sil`,onClick:()=>Qe(e.id,t._id)},`×`))))),X(`div`,{class:`muted`,style:{marginTop:`4px`}},`Ayrıntılı düzenleme için yönetim sayfasını kullanın.`)):null)}))):e.append(X(`div`,{class:`muted`},`Henüz veri seti yok. Yukarıdan kaydedin ya da Aktar sekmesinden içe aktarın.`))}renderIo(e){let t=V(),n=t.datasets[0]?.id,r=``,i=async e=>{try{this.toast(await e())}catch(e){this.toast(e instanceof J?e.message:`İçe aktarılamadı: `+e.message,`err`)}},a=X(`input`,{type:`file`,accept:`.json,.csv,application/json,text/csv`,multiple:!0,style:{display:`none`},onChange:e=>{let t=Array.from(e.target.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${mt(await pt(n,this.importMode))}`);return e.join(` · `)})}}),o=X(`div`,{class:`drop`,onClick:()=>a.click(),onDragover:e=>{e.preventDefault(),o.classList.add(`over`)},onDragleave:()=>o.classList.remove(`over`),onDrop:e=>{e.preventDefault(),o.classList.remove(`over`);let t=Array.from(e.dataTransfer?.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${mt(await pt(n,this.importMode))}`);return e.join(` · `)})}},`JSON / CSV dosyasını buraya bırakın ya da tıklayıp seçin`),s=(e,t,n)=>X(`label`,{class:`opt`},X(`input`,{type:`radio`,name:`mode`,checked:this.importMode===e,onChange:()=>{this.importMode=e}}),X(`span`,{},X(`b`,{},t),X(`span`,{class:`muted`},` · ${n}`)));e.append(X(`div`,{class:`sec`},`Dışa aktar`),X(`div`,{class:`row`},X(`button`,{class:`btn pri`,onClick:()=>ut({fields:!0,datasets:!0})},`Hepsi (JSON)`),X(`button`,{class:`btn`,onClick:()=>ut({fields:!0},`otofill-alanlar-${location.hostname}.json`)},`Alan tanımları`),X(`button`,{class:`btn`,onClick:()=>ut({datasets:!0},`otofill-veri.json`)},`Veri setleri`)),t.datasets.length?X(`div`,{class:`row`},X(`select`,{class:`grow`,onChange:e=>{n=e.target.value}},t.datasets.map(e=>X(`option`,{value:e.id},e.name))),X(`button`,{class:`btn`,onClick:()=>n&&dt(n)},`CSV (Excel)`)):``,X(`div`,{class:`sec`},`İçe aktar`),s(`merge`,`Birleştir`,`aynı kayıtları günceller, yenileri ekler`),s(`replace`,`Üzerine yaz`,`dosyadaki bölümü tamamen değiştirir`),s(`copy`,`Kopya olarak ekle`,`hepsini yeni kayıt olarak ekler`),o,a,X(`textarea`,{placeholder:`ya da JSON / CSV metnini buraya yapıştırın`,onInput:e=>{r=e.target.value}}),X(`div`,{class:`row`},X(`button`,{class:`btn grow`,onClick:()=>i(()=>mt(ft(r,this.importMode,r.trimStart().startsWith(`{`)?`yapistirilan.json`:`Yapıştırılan ${new Date().toLocaleString(`tr-TR`)}.csv`)))},`Metinden içe aktar`)),X(`div`,{class:`sec`},`Depolama`),X(`div`,{class:`muted`},`Veriler yalnızca bu tarayıcıda, ${location.origin} için saklanır; hiçbir yere gönderilmez. ${t.fields.length} alan tanımı, ${t.datasets.length} veri seti. Sürüm 0.1.1.`),X(`div`,{class:`row`},X(`button`,{class:`btn dng`,onClick:()=>{confirm(`${location.origin} için kayıtlı tüm Otofill alanları ve verileri silinsin mi? Bu işlem geri alınamaz; önce dışa aktarmanız önerilir.`)&&(Ge(),this.toast(`Tüm veriler silindi.`))}},`Bu sitedeki tüm verileri sil`)))}targetRectEl(e){return e.getClientRects().length&&e.getBoundingClientRect().width>2?e:e.closest(`label`)??e.parentElement??e}boxFor(e,t){let n=this.targetRectEl(e).getBoundingClientRect();return X(`div`,{class:`hl ${t}`,style:{left:`${n.left-3}px`,top:`${n.top-3}px`,width:`${n.width+6}px`,height:`${n.height+6}px`}})}hover(e){this.hoverEl=e,this.drawLayer()}flash(e){let t=this.boxFor(e,`green`);this.layer.appendChild(t),setTimeout(()=>t.style.opacity=`0`,700),setTimeout(()=>t.remove(),1200)}drawLayer(){let e=[...this.layer.querySelectorAll(`.pop, .teachbar`)];if(this.layer.replaceChildren(...e),!this.visible&&!this.teaching)return;let t=this.result;if(t&&(this.inspecting||this.teaching)){for(let e of t.matches){let t=this.targetRectEl(e.fp.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(X(`div`,{class:`badge`,style:{left:`${t.left}px`,top:`${t.top}px`}},`${e.def.key} · ${e.score}`))}if(this.inspecting)for(let e of t.free){let t=this.targetRectEl(e.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(X(`div`,{class:`badge free`,style:{left:`${t.left}px`,top:`${t.top}px`}},`? tanımsız`))}}this.hoverEl?.isConnected&&this.layer.appendChild(this.boxFor(this.hoverEl,``))}startTeach(){if(this.mount(),this.teaching)return;this.teaching=!0,this.pattern||=u(),this.visible||this.show(),this.result=W(),this.render();let e=X(`div`,{class:`teachbar`},X(`span`,{},`Tanıtma modu: bir alana tıklayın`),X(`button`,{onClick:()=>this.stopTeach()},`Bitir (Esc)`));this.layer.appendChild(e);for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.addEventListener(e,this.onTeachPointer,!0);document.addEventListener(`mousemove`,this.onTeachMove,!0),this.drawLayer()}stopTeach(){if(this.teaching){this.teaching=!1,this.closeTeachPop(),this.layer.querySelector(`.teachbar`)?.remove();for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.removeEventListener(e,this.onTeachPointer,!0);document.removeEventListener(`mousemove`,this.onTeachMove,!0),this.hoverEl=null,this.visible?this.refresh():this.drawLayer()}}fromPanel(e){return e.composedPath().includes(this.host)}closeTeachPop(){this.teachPop?.remove(),this.teachPop=null}openTeachPop(e){this.closeTeachPop();let t=y(e)===`radio`?O(e)[0]:e,n=j(document).find(e=>e.el===t);if(!n){this.toast(`Bu alan görünür değil ya da devre dışı.`,`err`);return}let r=V(),i=W();this.result=i;let a=i.matches.find(e=>e.fp.el===t)?.def,l=[...new Set([...r.fields.map(e=>e.key),...r.datasets.flatMap(U)])].sort(),ee=`otofill-keys`,d=u(),f=te(),p=a?.pages[0]??(this.pattern||d),m=X(`input`,{type:`text`,list:ee,value:a?.key??(o(n.label||n.name||n.placeholder||n.id)||``),placeholder:`ör. musteri.tckn`}),ne=X(`input`,{type:`text`,value:a?.title??n.label??``,placeholder:`Açıklama (isteğe bağlı)`}),h=X(`select`,{},X(`option`,{value:d,selected:p===d||void 0},`Bu sayfa`),X(`option`,{value:f,selected:p===f||void 0},`Tüm site`),p!==d&&p!==f?X(`option`,{value:p,selected:!0},p):null),re=(t.getAttribute(`type`)??``).toLowerCase()===`password`,g=r.datasets.some(e=>e.id===this.teachTarget.dsId)?this.teachTarget.dsId:(r.datasets.find(e=>e.id===r.prefs.lastDatasetId)??r.datasets[0])?.id??`__new`,_=g!==`__new`&&r.datasets.find(e=>e.id===g)?.rows.some(e=>e._id===this.teachTarget.rowId)?this.teachTarget.rowId:`__new`,v=()=>r.datasets.find(e=>e.id===g)?.rows.find(e=>e._id===_),b=()=>{let e=m.value.trim(),n=e?v()?.[e]:void 0;return n===void 0?re?``:R(t)??``:n},x=t.tagName===`SELECT`?Array.from(t.options).filter(e=>e.value!==``&&!e.disabled).map(e=>e.text.trim()).filter(Boolean):n.kind===`radio`?O(t).map(e=>k(e)||e.value):n.kind===`checkbox`?[`evet`,`hayır`]:[],S=X(`input`,{type:`text`,list:x.length?`otofill-choices`:void 0,value:b(),placeholder:re?`test hesabının şifresi (isteğe bağlı)`:`boş bırakılırsa veri yazılmaz`}),C=X(`select`,{class:`grow`}),w=X(`select`,{class:`grow`}),T=()=>{C.replaceChildren(...r.datasets.map(e=>X(`option`,{value:e.id,selected:e.id===g||void 0},e.name)),X(`option`,{value:`__new`,selected:g===`__new`||void 0},`+ Yeni veri seti`));let e=r.datasets.find(e=>e.id===g);w.replaceChildren(...(e?.rows??[]).map((e,t)=>X(`option`,{value:e._id,selected:e._id===_||void 0},`${t+1}. ${K(e)}`)),X(`option`,{value:`__new`,selected:_===`__new`||void 0},`+ Yeni satır`))};T(),C.addEventListener(`change`,()=>{g=C.value,_=`__new`,T(),S.value=b()}),w.addEventListener(`change`,()=>{_=w.value,S.value=b()}),m.addEventListener(`change`,()=>{let e=v()?.[m.value.trim()];e!==void 0&&(S.value=e)});let ie=()=>{let e=m.value.trim();if(!e){m.focus();return}let r=this.defFrom(n,e,ne.value.trim()||void 0,[h.value],a?.id),i=S.value,o=``;H(t=>{let n=t.fields.findIndex(e=>e.id===r.id);if(n>=0?t.fields[n]=r:t.fields.push(r),i.trim()===``)return;let a=t.datasets.find(e=>e.id===g);a||(a={id:s(),name:`Veri ${new Date().toLocaleDateString(`tr-TR`)}`,rows:[],updatedAt:c()},t.datasets.push(a));let l=a.rows.find(e=>e._id===_);l||(l={_id:s()},a.rows.push(l)),l[e]=i,a.updatedAt=c(),t.prefs.lastDatasetId=a.id,this.teachTarget={dsId:a.id,rowId:l._id},o=`${a.name} › ${a.rows.indexOf(l)+1}. satır`}),this.closeTeachPop(),this.flash(t),this.toast(`"${e}" ${a?`güncellendi`:`tanımlandı`}`+(o?`, değer → ${o}.`:`.`))},E=this.targetRectEl(t).getBoundingClientRect(),D=E.bottom+8+400>window.innerHeight?Math.max(8,E.top-400-8):E.bottom+8,ae=Math.min(Math.max(8,E.left),window.innerWidth-310);this.teachPop=X(`div`,{class:`pop`,style:{left:`${ae}px`,top:`${D}px`},onKeydown:e=>{e.key===`Enter`&&ie()}},X(`div`,{},X(`b`,{},a?`Alanı düzenle`:`Alan tanıt`),X(`span`,{class:`muted`},` · ${yt[n.kind]}${n.label?` · "${n.label}"`:``}`)),X(`span`,{class:`lbl`},`Anahtar (veri setindeki sütun adı)`),m,X(`datalist`,{id:ee},l.map(e=>X(`option`,{value:e}))),X(`span`,{class:`lbl`},`Açıklama`),ne,X(`span`,{class:`lbl`},`Geçerli olduğu yer`),h,X(`div`,{class:`sep`}),X(`span`,{class:`lbl`},`Örnek değer (isteğe bağlı)`),S,x.length?X(`datalist`,{id:`otofill-choices`},x.map(e=>X(`option`,{value:e}))):null,re?X(`span`,{class:`lbl warn`},`Gerçek şifrenizi yazmayın: veriler tarayıcıda düz metin durur ve dışa aktarılınca paylaşılır.`):null,X(`span`,{class:`lbl`},`Değerin yazılacağı yer`),X(`div`,{class:`row`},C,w),X(`div`,{class:`row`},a?X(`button`,{class:`btn dng`,onClick:()=>{qe(a.id),this.closeTeachPop(),this.toast(`"${a.key}" silindi.`)}},`Sil`):null,X(`span`,{class:`grow`}),X(`button`,{class:`btn`,onClick:()=>this.closeTeachPop()},`İptal`),X(`button`,{class:`btn pri`,onClick:ie},`Kaydet`))),this.layer.appendChild(this.teachPop),m.focus(),m.select()}},Et=n({BUNDLE_FORMAT:()=>q,BUNDLE_VERSION:()=>1,THRESHOLD:()=>30,WEIGHTS:()=>Ne,analyze:()=>W,close:()=>kt,fill:()=>Mt,fillElement:()=>Me,fillRow:()=>G,fingerprint:()=>A,init:()=>$,io:()=>nt,labelOf:()=>D,matchFields:()=>Ie,open:()=>Ot,readElement:()=>R,readRow:()=>$e,registerDriver:()=>Ae,scanPage:()=>j,score:()=>Fe,setNativeValue:()=>P,store:()=>Le,teach:()=>jt,toggle:()=>At,version:()=>Dt}),Dt=`0.1.1`,Q=null;function $(e={}){if(Q||typeof document>`u`)return;Q=new Tt({hotkey:gt(e.hotkey??`ctrl+q`)});let t=()=>Q.mount();document.body?t():document.addEventListener(`DOMContentLoaded`,t,{once:!0})}function Ot(){$(),Q.show()}function kt(){Q?.hide()}function At(){$(),Q.toggle()}function jt(){$(),Q.startTeach()}async function Mt(e,t=0){let n=V().datasets.find(t=>t.id===e||t.name===e);if(!n)throw Error(`Veri seti bulunamadı: ${e}`);let r=typeof t==`number`?n.rows[t]:n.rows.find(e=>e._label===t||e._id===t);if(!r)throw Error(`Satır bulunamadı: ${t}`);return G(r)}var Nt=globalThis,Pt=document.currentScript;return Nt.__optonaOtofill?Nt.__optonaOtofill.open():(Nt.__optonaOtofill=Et,Pt?.dataset.auto!==`false`&&$({hotkey:Pt?.dataset.hotkey}),Pt?.dataset.open===`true`&&Ot()),e.BUNDLE_FORMAT=q,e.BUNDLE_VERSION=tt,e.THRESHOLD=Pe,e.WEIGHTS=Ne,e.analyze=W,e.close=kt,e.fill=Mt,e.fillElement=Me,e.fillRow=G,e.fingerprint=A,e.init=$,Object.defineProperty(e,"io",{enumerable:!0,get:function(){return nt}}),e.labelOf=D,e.matchFields=Ie,e.open=Ot,e.readElement=R,e.readRow=$e,e.registerDriver=Ae,e.scanPage=j,e.score=Fe,e.setNativeValue=P,Object.defineProperty(e,"store",{enumerable:!0,get:function(){return Le}}),e.teach=jt,e.toggle=At,e.version=Dt,e})({});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Driver } from './types';
|
|
2
|
+
import { setNativeValue } from './fill-utils';
|
|
3
|
+
export { setNativeValue };
|
|
4
|
+
export declare const truthy: (v: string) => boolean;
|
|
5
|
+
/** Özel sürücü kaydeder; yerleşik sürücülerden önce denenir. */
|
|
6
|
+
export declare function registerDriver(d: Driver): void;
|
|
7
|
+
export declare function driverFor(el: Element): Driver | undefined;
|
|
8
|
+
export declare function fillElement(el: Element, value: string): Promise<boolean>;
|
|
9
|
+
export declare function readElement(el: Element): string | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DataRow, DataSet, FieldDef } from './types';
|
|
2
|
+
import type { MatchResult } from './matcher';
|
|
3
|
+
/** Bulunulan sayfayı tarar ve kayıtlı tanımlarla eşler. */
|
|
4
|
+
export declare function analyze(defs?: FieldDef[], url?: string): MatchResult;
|
|
5
|
+
export interface FillResult {
|
|
6
|
+
filled: string[];
|
|
7
|
+
/** Tanımlı ama sayfada bulunamayan anahtarlar. */
|
|
8
|
+
notFound: string[];
|
|
9
|
+
/** Bulundu ama değer yazılamadı (ör. select'te seçenek yok). */
|
|
10
|
+
failed: string[];
|
|
11
|
+
/** Sayfada var ama satırda değeri olmayanlar. */
|
|
12
|
+
noValue: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Satırı sayfaya yazar. Bağımlı alanlar (il → ilçe gibi) sonradan yüklenebildiği için
|
|
16
|
+
* yazılamayan ya da bulunamayan alanlar kısa aralıklarla yeniden denenir.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fillRow(row: DataRow, opts?: {
|
|
19
|
+
retries?: number;
|
|
20
|
+
delay?: number;
|
|
21
|
+
onFilled?: (el: Element) => void;
|
|
22
|
+
}): Promise<FillResult>;
|
|
23
|
+
/** Sayfadaki tanımlı alanların o anki değerlerini satır olarak okur. */
|
|
24
|
+
export declare function readRow(result?: MatchResult): Omit<DataRow, '_id'>;
|
|
25
|
+
/** Sayfadaki anahtarlarla en çok örtüşen veri setleri önce. */
|
|
26
|
+
export declare function rankDatasets(datasets: DataSet[], pageKeys: string[]): {
|
|
27
|
+
ds: DataSet;
|
|
28
|
+
overlap: number;
|
|
29
|
+
}[];
|
|
30
|
+
export declare function rowTitle(row: DataRow, keys?: string[]): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ValueEl = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
|
|
2
|
+
export declare function fire(el: Element, type: string): void;
|
|
3
|
+
export declare function pressKey(el: Element, key: string): void;
|
|
4
|
+
/**
|
|
5
|
+
* Vue v-model (ve React) değeri `input` olayıyla okur; `el.value = x` tek başına yetmez.
|
|
6
|
+
* Değeri prototipteki native setter ile yazıp olayları tetikliyoruz.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setNativeValue(el: ValueEl, value: string): void;
|
|
9
|
+
export declare function isShown(el: Element | null | undefined): el is Element;
|
|
10
|
+
/** Koşul sağlanana kadar bekler; zaman aşımında null döner. */
|
|
11
|
+
export declare function waitFor<T>(fn: () => T | null | undefined | false, timeout?: number, step?: number): Promise<T | null>;
|
|
12
|
+
/** Seçenekler arasından metne göre en iyi eşleşmeyi bulur: tam, baş, benzer. */
|
|
13
|
+
export declare function pickByText<T extends Element>(items: T[], value: string, text?: (e: T) => string): T | undefined;
|
|
14
|
+
/** Çoklu değer ayırıcı: "Spor | Müzik" */
|
|
15
|
+
export declare const splitMulti: (v: string) => string[];
|
|
16
|
+
/** Bir tarihi farklı yazım biçimlerinde dener: girilen, ISO, 31.12.1990, 31/12/1990, 12/31/1990, 1990/12/31. */
|
|
17
|
+
export declare function dateCandidates(value: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Bileşen yazılan değeri aynen kabul etti mi? Gösterilen değerin sayıları yazılanla aynı sırada başlamalı
|
|
20
|
+
* ("09:15" → "09:15:00" olur). Sıra farklıysa bileşen başka biçimle okuyup gün/ayı karıştırmış olabilir.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sameNumbers(shown: string, typed: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { analyze, fillRow, readRow } from './engine';
|
|
2
|
+
export declare const version: string;
|
|
3
|
+
export interface InitOptions {
|
|
4
|
+
/** Paneli açan kısayol. Varsayılan "ctrl+q". */
|
|
5
|
+
hotkey?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Kısayolu dinlemeye başlar. Birden fazla çağrılırsa ilk çağrı geçerlidir. */
|
|
8
|
+
export declare function init(opts?: InitOptions): void;
|
|
9
|
+
export declare function open(): void;
|
|
10
|
+
export declare function close(): void;
|
|
11
|
+
export declare function toggle(): void;
|
|
12
|
+
/** Tıklayarak alan tanıtma modunu başlatır. */
|
|
13
|
+
export declare function teach(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Programatik doldurma (testlerde, konsolda). Veri seti adı ya da id'si, satır sırası ya da _label verilir.
|
|
16
|
+
* Örn: Otofill.fill('Bireysel müşteriler', 0)
|
|
17
|
+
*/
|
|
18
|
+
export declare function fill(dataset: string, row?: number | string): Promise<import("./engine").FillResult>;
|
|
19
|
+
export { analyze, fillRow, readRow };
|
|
20
|
+
export { registerDriver, fillElement, readElement, setNativeValue } from './drivers';
|
|
21
|
+
export { scanPage, fingerprint, labelOf } from './scanner';
|
|
22
|
+
export { matchFields, score, THRESHOLD, WEIGHTS } from './matcher';
|
|
23
|
+
export * as store from './store';
|
|
24
|
+
export type { State, Prefs } from './store';
|
|
25
|
+
export * as io from './io';
|
|
26
|
+
export * from './types';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Bundle, DataSet, ImportMode } from './types';
|
|
2
|
+
import type { State } from './store';
|
|
3
|
+
export interface ExportOptions {
|
|
4
|
+
fields?: boolean;
|
|
5
|
+
/** true: hepsi, dizi: yalnızca bu id'ler, false: hiçbiri. */
|
|
6
|
+
datasets?: boolean | string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function makeBundle(state?: State, opts?: ExportOptions): Bundle;
|
|
9
|
+
export declare class ImportError extends Error {
|
|
10
|
+
}
|
|
11
|
+
/** Dosyayı doğrular, eksikleri tamamlar ve eski sürümleri günceller. Hatalıysa ImportError fırlatır. */
|
|
12
|
+
export declare function validateBundle(raw: unknown): Bundle;
|
|
13
|
+
export interface ImportSummary {
|
|
14
|
+
fieldsAdded: number;
|
|
15
|
+
fieldsUpdated: number;
|
|
16
|
+
datasetsAdded: number;
|
|
17
|
+
datasetsUpdated: number;
|
|
18
|
+
rows: number;
|
|
19
|
+
}
|
|
20
|
+
/** Paketi duruma uygular (kaydetmez). */
|
|
21
|
+
export declare function applyBundle(state: State, b: Bundle, mode: ImportMode): ImportSummary;
|
|
22
|
+
/** Excel (Türkçe) ile uyumlu olsun diye ; ayırıcı ve UTF-8 BOM kullanılır. */
|
|
23
|
+
export declare function datasetToCsv(ds: DataSet, keys?: string[]): string;
|
|
24
|
+
export declare function parseCsv(text: string): string[][];
|
|
25
|
+
/** CSV'den veri seti üretir. Başlık satırı anahtarlardır; "_label" (ya da "Etiket") sütunu satır adıdır. */
|
|
26
|
+
export declare function csvToDataset(text: string, name: string): DataSet;
|
|
27
|
+
export declare function download(filename: string, text: string, mime?: string): void;
|
|
28
|
+
export declare function exportJson(opts?: ExportOptions, filename?: string): void;
|
|
29
|
+
export declare function exportCsv(datasetId: string): void;
|
|
30
|
+
/** JSON ya da CSV metnini içe aktarır ve kaydeder. */
|
|
31
|
+
export declare function importText(text: string, mode: ImportMode, filename?: string): ImportSummary;
|
|
32
|
+
export declare function importFile(file: File, mode: ImportMode): Promise<ImportSummary>;
|
|
33
|
+
export declare function summaryText(s: ImportSummary): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FieldDef, Fingerprint } from './types';
|
|
2
|
+
/** Sinyal ağırlıkları. data-otofill eşleşmesi kesindir. */
|
|
3
|
+
export declare const WEIGHTS: {
|
|
4
|
+
otofill: number;
|
|
5
|
+
id: number;
|
|
6
|
+
name: number;
|
|
7
|
+
labelExact: number;
|
|
8
|
+
css: number;
|
|
9
|
+
labelFuzzy: number;
|
|
10
|
+
placeholder: number;
|
|
11
|
+
ariaLabel: number;
|
|
12
|
+
type: number;
|
|
13
|
+
index: number;
|
|
14
|
+
mismatch: number;
|
|
15
|
+
wrongTag: number;
|
|
16
|
+
wrongKind: number;
|
|
17
|
+
};
|
|
18
|
+
/** Bu puanın altındaki eşleşmeler kullanılmaz: yanlış alanı doldurmaktansa boş bırakmak iyidir. */
|
|
19
|
+
export declare const THRESHOLD = 30;
|
|
20
|
+
export declare function score(def: Pick<FieldDef, 'match' | 'kind'>, fp: Fingerprint): number;
|
|
21
|
+
export interface FieldMatch {
|
|
22
|
+
def: FieldDef;
|
|
23
|
+
fp: Fingerprint;
|
|
24
|
+
score: number;
|
|
25
|
+
}
|
|
26
|
+
export interface MatchResult {
|
|
27
|
+
/** Bu sayfaya uygulanan tanımlar. */
|
|
28
|
+
defs: FieldDef[];
|
|
29
|
+
matches: FieldMatch[];
|
|
30
|
+
/** Tanımlı ama sayfada bulunamayanlar. */
|
|
31
|
+
missing: FieldDef[];
|
|
32
|
+
/** Sayfada olup hiçbir tanıma uymayan alanlar. */
|
|
33
|
+
free: Fingerprint[];
|
|
34
|
+
}
|
|
35
|
+
/** Tanımları sayfadaki alanlarla eşler; en yüksek puandan başlayarak her alan en fazla bir kez kullanılır. */
|
|
36
|
+
export declare function matchFields(allDefs: FieldDef[], fps: Fingerprint[], url?: string): MatchResult;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Child = Node | string | number | null | undefined | false | Child[];
|
|
2
|
+
type Props = Record<string, unknown>;
|
|
3
|
+
/** Küçük DOM yardımcısı: h('button', { class: 'x', onClick }, 'Metin') */
|
|
4
|
+
export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, props?: Props, ...children: Child[]): HTMLElementTagNameMap[K];
|
|
5
|
+
export declare function append(el: Node, children: Child[]): void;
|
|
6
|
+
export interface Hotkey {
|
|
7
|
+
ctrl: boolean;
|
|
8
|
+
shift: boolean;
|
|
9
|
+
alt: boolean;
|
|
10
|
+
meta: boolean;
|
|
11
|
+
code: string;
|
|
12
|
+
}
|
|
13
|
+
/** "ctrl+q", "ctrl+shift+f" → Hotkey */
|
|
14
|
+
export declare function parseHotkey(s: string): Hotkey;
|
|
15
|
+
export declare function hotkeyMatches(e: KeyboardEvent, k: Hotkey): boolean;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Hotkey } from './dom';
|
|
2
|
+
export interface PanelOptions {
|
|
3
|
+
hotkey: Hotkey;
|
|
4
|
+
}
|
|
5
|
+
export declare class Panel {
|
|
6
|
+
private opts;
|
|
7
|
+
private host;
|
|
8
|
+
private root;
|
|
9
|
+
private box;
|
|
10
|
+
private layer;
|
|
11
|
+
private visible;
|
|
12
|
+
private view;
|
|
13
|
+
private result;
|
|
14
|
+
private lastFill;
|
|
15
|
+
private dsId?;
|
|
16
|
+
private openDsId?;
|
|
17
|
+
private toastMsg;
|
|
18
|
+
private toastKind;
|
|
19
|
+
private toastTimer;
|
|
20
|
+
private pattern;
|
|
21
|
+
private importMode;
|
|
22
|
+
private inspecting;
|
|
23
|
+
private teaching;
|
|
24
|
+
private teachPop;
|
|
25
|
+
private freeSel;
|
|
26
|
+
/** Tanıtırken girilen değerlerin yazılacağı veri seti ve satır (sonraki tanıtmalarda hatırlanır). */
|
|
27
|
+
private teachTarget;
|
|
28
|
+
private ui;
|
|
29
|
+
private mini;
|
|
30
|
+
private minimized;
|
|
31
|
+
private miniMsg;
|
|
32
|
+
private raf;
|
|
33
|
+
constructor(opts: PanelOptions);
|
|
34
|
+
mount(): void;
|
|
35
|
+
show(): void;
|
|
36
|
+
hide(): void;
|
|
37
|
+
toggle(): void;
|
|
38
|
+
/** Paneli tek bir küçük düğmeye çevirir (konumu panelin sağ üst köşesi). */
|
|
39
|
+
minimize(): void;
|
|
40
|
+
private showMini;
|
|
41
|
+
/** Kayıtlı boyut ve konumu panele uygular. */
|
|
42
|
+
private applyBox;
|
|
43
|
+
/** Bu sayfa için en uygun veri setinde son kullanılan satır (yoksa ilk satır). */
|
|
44
|
+
private quickTarget;
|
|
45
|
+
private renderMini;
|
|
46
|
+
/** Küçük düğmeden doldurma: veri yoksa ya da sorun çıkarsa paneli açar. */
|
|
47
|
+
private quickFill;
|
|
48
|
+
isOpen(): boolean;
|
|
49
|
+
refresh(): void;
|
|
50
|
+
private toast;
|
|
51
|
+
private onKey;
|
|
52
|
+
private currentDataset;
|
|
53
|
+
private pageKeys;
|
|
54
|
+
private fillWith;
|
|
55
|
+
private fillNext;
|
|
56
|
+
private fillRandom;
|
|
57
|
+
private render;
|
|
58
|
+
private renderFill;
|
|
59
|
+
private renderFields;
|
|
60
|
+
private saveFree;
|
|
61
|
+
private defFrom;
|
|
62
|
+
private renderData;
|
|
63
|
+
private renderIo;
|
|
64
|
+
private startDrag;
|
|
65
|
+
/** Küçük düğme de boş kısmından sürüklenebilir. */
|
|
66
|
+
private startMiniDrag;
|
|
67
|
+
private hoverEl;
|
|
68
|
+
private targetRectEl;
|
|
69
|
+
private boxFor;
|
|
70
|
+
private hover;
|
|
71
|
+
private flash;
|
|
72
|
+
private onViewport;
|
|
73
|
+
private drawLayer;
|
|
74
|
+
startTeach(): void;
|
|
75
|
+
stopTeach(): void;
|
|
76
|
+
private fromPanel;
|
|
77
|
+
private onTeachMove;
|
|
78
|
+
private onTeachPointer;
|
|
79
|
+
private closeTeachPop;
|
|
80
|
+
private openTeachPop;
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.panel {\n position: fixed; top: 16px; right: 16px; width: 380px; max-height: calc(100vh - 32px);\n display: flex; flex-direction: column; background: #fff; color: #1f2937; font-size: 13px; line-height: 1.4;\n border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.22); z-index: 2147483646; overflow: hidden;\n resize: both; min-width: 300px; min-height: 160px; max-width: calc(100vw - 16px);\n}\n.ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }\n.head button .ico { vertical-align: middle; }\n.mini {\n position: fixed; z-index: 2147483646; display: flex; align-items: center; gap: 2px; padding: 3px;\n background: #111827; border-radius: 20px; box-shadow: 0 6px 20px rgba(0,0,0,.3); cursor: move; user-select: none;\n}\n.mini button { border: 0; cursor: pointer; color: #fff; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }\n.mini .mfill { background: #2563eb; border-radius: 16px; padding: 5px 11px; font-weight: 600; }\n.mini .mfill:hover { background: #1d4ed8; }\n.mini .mfill.off { background: #4b5563; }\n.mini .mico { background: transparent; color: #d1d5db; width: 26px; height: 26px; border-radius: 13px; justify-content: center; font-size: 16px; }\n.mini .mico:hover { background: #374151; color: #fff; }\n.head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #111827; color: #fff; cursor: move; user-select: none; }\n.head b { font-size: 13px; letter-spacing: .2px; }\n.head .sub { color: #9ca3af; font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.head button { background: transparent; border: 0; color: #d1d5db; font-size: 16px; cursor: pointer; padding: 0 4px; }\n.tabs { display: flex; border-bottom: 1px solid #e5e7eb; background: #f9fafb; }\n.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 4px; cursor: pointer; font-size: 12px; color: #4b5563; border-bottom: 2px solid transparent; }\n.tabs button.on { color: #111827; border-bottom-color: #2563eb; font-weight: 600; }\n.body { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }\n.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }\n.muted { color: #6b7280; font-size: 12px; }\n.sec { font-weight: 600; font-size: 12px; color: #374151; margin-top: 2px; }\nbutton.btn { border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; color: #1f2937; }\nbutton.btn:hover { background: #f3f4f6; }\nbutton.pri { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.pri:hover { background: #1d4ed8; }\nbutton.dng { color: #b91c1c; border-color: #fca5a5; }\nbutton.sm { padding: 2px 6px; font-size: 11px; }\nbutton:disabled { opacity: .5; cursor: default; }\ninput[type=text], select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 5px 7px; font-size: 12px; color: #111827; background: #fff; min-width: 0; }\ninput[type=text]:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }\ntextarea { width: 100%; min-height: 70px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }\n.grow { flex: 1; }\n.list { display: flex; flex-direction: column; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }\n.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid #f3f4f6; }\n.item:first-child { border-top: 0; }\n.item.click { cursor: pointer; }\n.item.click:hover, .item.cur { background: #eff6ff; }\n.num { min-width: 18px; height: 18px; border-radius: 4px; background: #e5e7eb; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; color: #374151; }\n.key { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #1e40af; }\n.ok { color: #15803d; } .bad { color: #b91c1c; } .warn { color: #b45309; }\n.toast { padding: 7px 9px; border-radius: 6px; font-size: 12px; }\n.toast.ok { background: #dcfce7; color: #14532d; } .toast.err { background: #fee2e2; color: #7f1d1d; }\n.drop { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 14px; text-align: center; color: #64748b; cursor: pointer; }\n.drop.over { border-color: #2563eb; background: #eff6ff; }\n.empty { padding: 14px; text-align: center; color: #6b7280; }\ntable { border-collapse: collapse; width: 100%; font-size: 11px; }\nth, td { border-bottom: 1px solid #f3f4f6; padding: 3px 4px; text-align: left; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\nth { color: #6b7280; font-weight: 600; }\nlabel.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }\n.layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483645; }\n.hl { position: fixed; border: 2px solid #2563eb; background: rgba(37,99,235,.08); border-radius: 4px; transition: opacity .4s; }\n.hl.green { border-color: #16a34a; background: rgba(22,163,74,.12); }\n.badge { position: fixed; transform: translateY(-100%); font: 600 10px/1.6 ui-monospace, Consolas, monospace; padding: 0 5px; border-radius: 4px 4px 4px 0; background: #16a34a; color: #fff; white-space: nowrap; }\n.badge.free { background: #6b7280; }\n.teachbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; pointer-events: auto; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }\n.teachbar button { background: #374151; color: #fff; border: 0; border-radius: 12px; padding: 3px 10px; cursor: pointer; }\n.pop { position: fixed; width: 300px; background: #fff; border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 10px; pointer-events: auto; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: #1f2937; }\n.pop .lbl { font-size: 11px; color: #6b7280; }\n.pop input[type=text], .pop select { width: 100%; }\n.pop .row select { width: auto; flex: 1; min-width: 0; }\n.pop .sep { border-top: 1px solid #e5e7eb; margin: 2px 0; }\n.pop .lbl.warn { color: #b45309; }\n";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FieldKind, Fingerprint } from './types';
|
|
2
|
+
export declare const HOST_TAG = "optona-otofill";
|
|
3
|
+
export declare function kindOf(el: Element): FieldKind;
|
|
4
|
+
export declare function isFieldElement(el: Element | null): boolean;
|
|
5
|
+
/** Tıklanan düğümden ilgili alanı bulur (label'a tıklandıysa bağlı input). */
|
|
6
|
+
export declare function fieldFromTarget(target: Element | null): Element | null;
|
|
7
|
+
export declare function isVisible(el: Element): boolean;
|
|
8
|
+
/** Alanın etiketini bulur: aria-labelledby, label[for], saran label, aria-label, form-item etiketi, yakın metin. */
|
|
9
|
+
export declare function labelOf(el: Element): string;
|
|
10
|
+
/** Aynı gruptaki radio'lar (aynı name, aynı form). */
|
|
11
|
+
export declare function radioGroup(el: Element): HTMLInputElement[];
|
|
12
|
+
/** Tek bir radio/checkbox seçeneğinin kendi etiketi ("Kadın", "Erkek"). */
|
|
13
|
+
export declare function optionLabel(el: Element): string;
|
|
14
|
+
export declare function fingerprint(el: Element, index?: number): Fingerprint;
|
|
15
|
+
/** Sayfadaki görünür alanları tarar. Radio grupları tek alan sayılır (ilk seçenek temsil eder). */
|
|
16
|
+
export declare function scanPage(root?: Document): Fingerprint[];
|
|
17
|
+
/** Parmak izinden saklanacak ipuçlarını üretir (el hariç). */
|
|
18
|
+
export declare function hintsOf(fp: Fingerprint): {
|
|
19
|
+
otofill?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
tag?: string;
|
|
26
|
+
type?: string;
|
|
27
|
+
css?: string;
|
|
28
|
+
formKey?: string;
|
|
29
|
+
index?: number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DataRow, DataSet, FieldDef } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Veriler bulunulan sitenin (origin) localStorage'ında durur; kütüphane hiçbir yere istek atmaz.
|
|
4
|
+
* Kod güncellense de veri silinmez. Biçim değişirse migrate() eski veriyi yükseltir.
|
|
5
|
+
*/
|
|
6
|
+
export declare const STORAGE_KEY = "optona-otofill";
|
|
7
|
+
export declare const STATE_VERSION = 1;
|
|
8
|
+
export interface Prefs {
|
|
9
|
+
lastDatasetId?: string;
|
|
10
|
+
/** Veri seti başına "sıradaki satır" imleci. */
|
|
11
|
+
cursor: Record<string, number>;
|
|
12
|
+
closeAfterFill: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface State {
|
|
15
|
+
v: number;
|
|
16
|
+
fields: FieldDef[];
|
|
17
|
+
datasets: DataSet[];
|
|
18
|
+
prefs: Prefs;
|
|
19
|
+
}
|
|
20
|
+
type Listener = (s: State) => void;
|
|
21
|
+
/** Eski sürümlerin verisini güncel biçime taşır. Yeni biçim eklendiğinde buraya adım eklenir. */
|
|
22
|
+
export declare function migrate(raw: unknown): State;
|
|
23
|
+
export declare function load(): State;
|
|
24
|
+
export declare function save(s: State): void;
|
|
25
|
+
/** Durumu okuyup değiştirir ve kaydeder. */
|
|
26
|
+
export declare function update(fn: (s: State) => void): State;
|
|
27
|
+
export declare function subscribe(fn: Listener): () => void;
|
|
28
|
+
export declare function clearAll(): void;
|
|
29
|
+
export declare function upsertField(def: Omit<FieldDef, 'id'> & {
|
|
30
|
+
id?: string;
|
|
31
|
+
}): FieldDef;
|
|
32
|
+
export declare function removeField(id: string): void;
|
|
33
|
+
export declare function createDataset(name: string, rows?: DataRow[]): DataSet;
|
|
34
|
+
export declare function upsertDataset(ds: DataSet): void;
|
|
35
|
+
export declare function removeDataset(id: string): void;
|
|
36
|
+
export declare function addRow(datasetId: string, row: Omit<DataRow, '_id'> & {
|
|
37
|
+
_id?: string;
|
|
38
|
+
}): DataRow;
|
|
39
|
+
export declare function removeRow(datasetId: string, rowId: string): void;
|
|
40
|
+
/** Veri setindeki tüm anahtarlar (sütunlar), _id/_label hariç. */
|
|
41
|
+
export declare function datasetKeys(ds: DataSet): string[];
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Alanın türü: hangi sürücünün dolduracağına ve eşlemeye yardım eder. */
|
|
2
|
+
export type FieldKind = 'text' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'date' | 'contenteditable' | 'other';
|
|
3
|
+
/** Bir alanı sayfada tanımak için saklanan ipuçları (parmak izi). */
|
|
4
|
+
export interface MatchHints {
|
|
5
|
+
/** data-otofill="..." attribute'u: varsa kesin eşleşme. */
|
|
6
|
+
otofill?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
tag?: string;
|
|
13
|
+
type?: string;
|
|
14
|
+
/** Üretilmiş CSS seçici. */
|
|
15
|
+
css?: string;
|
|
16
|
+
/** İçinde bulunduğu formun id/name değeri. */
|
|
17
|
+
formKey?: string;
|
|
18
|
+
/** Sayfadaki alanlar arasındaki sırası. */
|
|
19
|
+
index?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Kullanıcının tanıttığı alan: "bu input şu anahtardır". */
|
|
22
|
+
export interface FieldDef {
|
|
23
|
+
id: string;
|
|
24
|
+
/** Veri setlerindeki sütun adı, ör. "musteri.tckn". */
|
|
25
|
+
key: string;
|
|
26
|
+
title?: string;
|
|
27
|
+
/** Geçerli olduğu sayfa adresleri, * joker. Boşsa her sayfada. */
|
|
28
|
+
pages: string[];
|
|
29
|
+
kind?: FieldKind;
|
|
30
|
+
match: MatchHints;
|
|
31
|
+
updatedAt?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Veri setindeki bir satır: anahtar → değer. Değerler her zaman metindir. */
|
|
34
|
+
export interface DataRow {
|
|
35
|
+
_id: string;
|
|
36
|
+
_label?: string;
|
|
37
|
+
[key: string]: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface DataSet {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
rows: DataRow[];
|
|
43
|
+
updatedAt?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const BUNDLE_FORMAT = "optona-otofill";
|
|
46
|
+
export declare const BUNDLE_VERSION = 1;
|
|
47
|
+
/** İçe/dışa aktarılan dosya. */
|
|
48
|
+
export interface Bundle {
|
|
49
|
+
format: typeof BUNDLE_FORMAT;
|
|
50
|
+
version: number;
|
|
51
|
+
exportedAt: string;
|
|
52
|
+
fields?: FieldDef[];
|
|
53
|
+
datasets?: DataSet[];
|
|
54
|
+
}
|
|
55
|
+
/** merge: aynı id'liyi güncelle, yeniyi ekle. replace: dosyadaki bölümü tamamen değiştir. copy: hepsini yeni kayıt olarak ekle. */
|
|
56
|
+
export type ImportMode = 'merge' | 'replace' | 'copy';
|
|
57
|
+
/** Sayfadaki bir alanın o anki parmak izi. */
|
|
58
|
+
export interface Fingerprint extends MatchHints {
|
|
59
|
+
el: Element;
|
|
60
|
+
kind: FieldKind;
|
|
61
|
+
}
|
|
62
|
+
/** Değeri alana yazan sürücü. Özel bileşenler (Element Plus select vb.) için kendi sürücünüzü kaydedebilirsiniz. */
|
|
63
|
+
export interface Driver {
|
|
64
|
+
name: string;
|
|
65
|
+
detect(el: Element): boolean;
|
|
66
|
+
/** Başarılıysa true döner; false dönerse kısa bir beklemeden sonra yeniden denenir. */
|
|
67
|
+
fill(el: Element, value: string): boolean | Promise<boolean>;
|
|
68
|
+
read?(el: Element): string | undefined;
|
|
69
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element Plus (2.x) sürücüleri. Gerçek input'lar gizli/salt okunur olduğu için değer, bileşenin
|
|
3
|
+
* kendi açılır listesinden tıklanarak seçilir. el-input, el-input-number, el-checkbox, el-radio,
|
|
4
|
+
* el-switch native sürücülerle çalışır; burada yalnızca özel davranışlı bileşenler var.
|
|
5
|
+
*/
|
|
6
|
+
import type { Driver } from '../types';
|
|
7
|
+
export declare const elementPlusDrivers: Driver[];
|